Strange symbol appears in GtkTreeView - c++

I am writting log viewer with GTK for Windows. I use GtkTreeView widget to display log records. It contains 3 columns: date & time, event source, event text. For any reason, in event time column strange symbol appears:
I used debugger watch window to see string value, and it doesn't contain any extra characters that can result in this strange symbol appearence.
What are possible reasons of such tree view behavior?

All text used in Gtk+-2.0 widgets needs to be in UTF8 encoding.Text in plain ASCII is automatically valid UTF8, but as soon as you have special characters that do not exist in plain ASCII (usually characters that are not used in the English language alphabet), they need to be in UTF8 encoding.Otherwise you may get what you are getting now.

This is something weird but gtk use to have this problem if you do not use glib library functions. You need to handle all of the strings with this functions. This could be a rendering issue.
for paths you use g_path_get_basename(path);
for dirs you use g_path_get_dirname (path);
for date and time use some of this docs gtk date and time
so it can be displayed properly in the treeview

Related

Django - suing font awersome in unicode form

I want to use font awersome in my project in the way, that user can choose which icon he wants. I found django-fontawesome-5 but there is one problem - there is no access to icon's unicode and I need it for one javascript component (html doesn't work there, and unicode does). I was looking all over the internet, but I coundn't find anything that would allow me to add font-awersome icons, with their unicodes somhow stored. My question is do you know how to get this feature?
The unicode codes are stored in icons.json and in icons_semantic_ui.json
Since you've got the codes source you can define a custom templatetag or a model/mixin method or a function which just gets a code from one of those json files using icon name
You can see example in fontawesome_5/utils.py

Using GetWindowTextW to get Hebrew text from edit control

I have a VisualStudio project set to "Use Multi-Byte Character Set. It's an older codebase and generally I've been able to get around ok using the "W" version of various functions. However I'm running into a problem trying to get a Hebrew string out of an edit control. No matter what I try I get question marks.
E.g.
int textLen = GetWindowTextLengthW(chatBoxHwnd);
wchar_t* buffw = new wchar_t[textLen + 1];
GetWindowTextW(chatBoxHwnd, buffw, textLen + 1);
But when I try to use buffw (such as displaying it with MessageBoxW) I still get question marks.
So the solution was to also use the Unicode version for creating the edit control itself ( CreateWindowExW vs CreateWindowEX) as well as the ancillary functions around that (SendMessageW, SetWindowLongPtrW, etc...)
After that I was able to successfully use the above code to pull Hebrew (and other languages) from the edit box.
Special thanks to this post How to create a unicode window in a non-unicode application

MFC: How to Set initial value of CMFCEditBrowseCtrl object?

I have MFC application for which I want to add one dialog to browse file location, using CMFCEditBrowseCtrl object. But I have not been able to set initial path properly, e.g. "C:\Program Files\Path".
When tried it is showing chinese letters.
How can i do that? I have the code as follows :
m_pathCtrl.EnableFolderBrowseButton();
m_pathCtrl.SetWindowText(_T("C:\\Program Files\\Path"));
But it is showing something like this ->
How to properly show the path in English? Please Guide.
The issue arises because you are using the ASCII character set, but the control expects Unicode. MS explains how to set up an CMFCEditBrowseCtrl in a dialog when using ASCII here: https://learn.microsoft.com/en-us/cpp/mfc/reference/cmfceditbrowsectrl-class?view=msvc-170. Use the dialog editor to insert an edit control in the dialog, then change its type from CEdit to CMFCEditBrowseCtrl in the header file.
You can also see the proper characters in the window by using SetWindowTextW; e g, inputFilesCtrl.SetWindowTextW(L"C:\SomeDirectory");. The Chinese characters you are seeing are what happens when a 1-byte character set is interpreted as a 2-byte one.

Weird character imported in Qt QString from a system action in osx

I have an app that at some point displays printer info.
On mac, when adding a printer, the default location is set as "me's iMac" unless user changes it. (me being the user name). But the apostrophe is not quite an apostrophe...
me’s iMac
This is how it shows in system printer dialog:
When I try to display the location in my app - using
QString(pCups->getValue("printer-location", i))
I get
How can I fix this substitution ? are they using a special font ? is there some way I can recognize it ?
I am thinking that if the user name contains other special characters, they may also be mapped to non-UTF-8 ones by the system add printer dialog. I don't have control over it... How can I find and fix any of the fancy symbols with standard ones ?
OSX 10.6-10.9
edit: for now I just did a replace with that specific character... But I think I may have other surprises if I don't do a more generic replace for all non-UTF-8 fancy characters
QString(pCups->getValue("printer-location", i)).replace("’", "'");
// this is what it looks like on Windows, though that particular item will only be used on unix (obviously... cups)
QString(pCups->getValue("printer-location", i)).replace("’", "'");
According to this page, QString interprets its C-style string argument as Latin-1 (ISO-8859-1), not UTF-8. The advice given is to always construct QStrings from C-style strings using QString::fromUtf8() instead.
There's an alternative noted on that page, but you are discouraged from using it because it's a process-global setting and therefore may interfere with libraries or the like. You can call QTextCodec::setCodecForCStrings() passing the UTF-8 text codec (QTextCodec::codecForName(“UTF-8”)) early in the startup of your app.

How to load qt linguist dynamically changed label text

In my project i'm trying to use qt linguist. When i change the language from English to Turkish, it is working all constant label.
But some labels i m loading them dynamically according to scenario of use cases.
Whatever i do with qt linguist, it doest workthe texts of these label.
How can i get rid of this problem?
Any help will be apprecialted
Qt has a guide to internationalization, which includes the basic information: to wrap your string in a tr function call.
label->setText( tr( "Hello, World!" ) );
In addition to this, if you want the language to change on the fly, you'll need to identify when the context has changed, and update your labels appropriately. Unfortunately, I can't easily put my hands on the signal that indicates when to do so.