global CP.UTF8
CP.UTF8 = hexdec("FDE9")
nomainwin
statictext #w.s1, "", 10, 10, 300, 100
open "Unicode test" for window as #w
#w "trapclose [quit]"
#w "font Times_New_Roman 20"
hws1 = hwnd(#w.s1)
call SetTextUnicode hws1, "Это демонстрация российского текста"
wait
[quit]
close #w
end
sub SetTextUnicode hwin, utf8$
slen = len(utf8$)
calldll #kernel32, "MultiByteToWideChar", _
CP.UTF8 as long, 0 as long, _
utf8$ as ptr, slen as long, _
0 as long, 0 as long, ret as long
wide$ = space$(2*ret)
calldll #kernel32, "MultiByteToWideChar", _
CP.UTF8 as long, 0 as long, _
utf8$ as ptr, slen as long, _
wide$ as ptr, ret as long, ret as long
wide$ = wide$ + chr$(0) + chr$(0)
calldll #user32, "SendMessageW", _
hwin as long, _WM_SETTEXT as long, _
0 as long, wide$ as ptr, ret as long
end sub