Using GetWindowTextW to get Hebrew text from edit control - c++

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

Related

Substitute Wingding fonts for linux

I am using Java aspose.words and trying to build a pdf from docx/ppt in linux. The docx-document has an list with bulletpoints. These bulletpoints use the symbol font.
When i create the pdf with aspose these bulletpoints are shown in webdings font as a clapperboard.
I did not find any free font (for commercial use) that is an equivalent to the symbol font. Does anyone know a good solution to show correct bulletpoints in list?
I found the way to substitute fonts, but i don't know which font to use:
TableSubstitutionRule tableSubstitutionRule = fontSettings.getSubstitutionSettings().getTableSubstitution();
tableSubstitutionRule.addSubstitutes("Symbol", "?WHICH_FONT?");
It might be a known peculiarity. Windows “Symbol” font is a symbolic font (like “Webdings”, “Wingdings”, etc.) which uses Unicode PUA. Thus substitution of this font will cause different glyphs rendering. Provided Mac/Linux “Symbol” font on the other hand is a proper Unicode font (for example Greek characters are in the U+0370…U+03FF Greek and Coptic block). So these fonts are incompatible and Mac/Linux “Symbol” font cannot be used instead of Windows “Symbol” without additional actions. In this particular case you have to change the bullet codepoint from PUA U+F0B7 (or U+00B7 which also can be used in MS Word for symbolic fonts) to the U+2022 in the document to use the Mac “Symbol” font. See the following code for example:
Document doc = new Document("/Users/mac1/Downloads/in.docx");
for (com.aspose.words.List lst : doc.getLists())
{
for (com.aspose.words.ListLevel level : lst.getListLevels())
{
if (level.getFont().getName().equals("Symbol") && level.getNumberFormat().equals("\uF0B7"))
{
level.setNumberFormat("\u2022");
}
}
}
doc.save("/Users/mac1/Downloads/out.pdf");
If this does not help, please post your question in Aspose.Words support forum and attach your input and output document there.

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

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.

Strange symbol appears in GtkTreeView

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