MessageBoxW and cyrillic captions

General FreeBASIC programming questions.
jj2007
Posts: 181
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

MessageBoxW and cyrillic captions

Postby jj2007 » Oct 31, 2017 8:37

Code: Select all

#include "windows.bi"
   MessageBoxW(0, "Это текст MessageBox", "Это подпись", MB_OK)
Looks simple, but on Windows 7-64 (and only there) the caption is not displayed properly. Works fine on XP and Win10, no problem with Chinese or Arabic, no problem for the MessageBox text, but a cyrillic caption on Windows 7-64 shows little squares instead of "Это подпись" (meaning "this is a caption").

There is a workaround: It displays fine with a Unicode BOM added.

Anybody around running Win7 who could confirm this behaviour? I would like to know if it's a general Windows 7 bug, or if it's limited to my machine, with an Italian Windows version.
dkl
Site Admin
Posts: 3174
Joined: Jul 28, 2005 14:45
Location: Germany

Re: MessageBoxW and cyrillic captions

Postby dkl » Oct 31, 2017 14:40

For putting Unicode into a string literal, the .bas file must have a BOM, causing string literals to be treated as WString. The rest depends on Windows (the GUI font must support rendering the glyphs).

Without BOM, fbc makes it a ZString and just puts the raw bytes into it, which depends on the text editor. (Also in this case there should be a compiler warning when calling MessageBoxW with a zstring.) If it's some Windows codepage (instead of Unicode) then it can only work if the system uses the same codepage at runtime. If it's UTF-8 it will probably work on GNU/Linux systems, because they use UTF8 everywhere anyways, but not Windows.
jj2007
Posts: 181
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: MessageBoxW and cyrillic captions

Postby jj2007 » Oct 31, 2017 15:47

The code is built with a BOM, and the MessageBoxW text displays fine. It is the caption that misbehaves.

In the meantime, it seems that the problem is system-wide: Even when opening a file with a cyrillic name in MS Word, I get the little squares. Notably, the caption looks correct if the caption string itself has a BOM (which I can't show with FB but tested in other languages).

This is on an Italian version of Win7-64. My suspicion is that it crept in a with a recent major Windows update.

Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests