Powerbasic Museum 2020-B

General Category => General Discussion => Topic started by: Patrice Terrier on December 31, 2011, 01:16:04 PM

Title: Unicode and MessageBox
Post by: Patrice Terrier on December 31, 2011, 01:16:04 PM
Do you know how we could display an UNICODE string with the standard MessageBox API.
I am unable to display correctly mandarin or cyrillic with it.

:-[
 
Title: Re: Unicode and MessageBox
Post by: José Roca on December 31, 2011, 01:37:21 PM
If you have it in a variable that already contains it as Unicode, simply use MessageBoxW.

If you need to use string literals, as the PB compiler does not compile unicode files you need to use UTF8:


MessageBoxW(0, Utf8ToChr$("官话"), "Simplified Chinese", %MB_OK)


where "官话" is "官话" UT8 encoded.
Title: Re: Unicode and MessageBox
Post by: Patrice Terrier on December 31, 2011, 02:58:32 PM
José, Thank you!

I have been trying to display a variable that already contains it as Unicode, but i couldn't get it to work.
It seems that the only way to have it working with PB, is to use Utf8ToChar$ wathever the variable being used.

...
Title: Re: Unicode and MessageBox
Post by: José Roca on December 31, 2011, 03:45:04 PM
The CSED editor allows you to use unicode literals, that are automatically converted to UTF8 when saved, and to unicode when displayed. Therefore, you can use:


MessageBoxW(0, Utf8ToChr$("官话"), "Simplified Chinese", %MB_OK)