BBC BASIC for Windows
Programming >> BBC BASIC language >> Unicode in dialog boxes
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1325180163

Unicode in dialog boxes
Post by JB91 on Dec 29th, 2011, 4:36pm

Hi,

How would you be able to put unicode strings in a static control in a dialog box? I've tried changing it into UTF-8, but it doesn't work.

Josh.
Re: Unicode in dialog boxes
Post by admin on Dec 29th, 2011, 5:15pm

on Dec 29th, 2011, 4:36pm, JB91 wrote:
How would you be able to put unicode strings in a static control in a dialog box? I've tried changing it into UTF-8, but it doesn't work.

Windows controls don't support UTF-8 natively; they only take UTF-16. You can convert the UTF-8 string to UTF-16 and send it to the static control as follows (requires BB4W v5.93a):

Code:
      L% = LEN(utf8$)+1
      utf16$ = STRING$(2*L%, CHR$0)
      SYS "MultiByteToWideChar", CP_UTF8, 0, utf8$, -1, utf16$, L%
      SYS "SetDlgItemTextW", !dlg%, idstatic%, utf16$ 

You will also need to ensure that a Unicode font is selected.

Richard.