Windows ime send the characters in there native codec. You can use Win Api to convert it. Here is the code I used for get chinese input.
Works with japanese input, but GetChar seems to fail to capture some chararcter, maybe it's because I'm not using a Japanese code page.
Extern "win32"
Function MultiByteToWideChar:Int (page:Int, flags:Int, src:Byte Ptr, srclen:Int, dst:Short Ptr, dstlen:Int)
Function WideCharToMultiByte:Int (page:Int, flags:Int, ..
src:Byte Ptr, srclen:Int, dst:Short Ptr, dstlen:Int, ..
defaultchar:String, fusedefault:Byte Ptr)
End Extern
Graphics 640, 480, 0
SetBlend ALPHABLEND
SetImageFont(LoadImageFont("c:/windows/fonts/msmincho.ttc", 25, 0))
Local s:String = ""
Local k:Int = 0
While Not KeyHit(KEY_ESCAPE)
s = ConvertUnicode(GetChars())
If s <> Null
DrawText s, k, 0
k:+s.Length * 25
End If
PollEvent()
Flip
Wend
Function GetChars:Byte[] ()
Local b:Byte[4096]
Local b1:Byte
Local n:Int = 0
Repeat
b1 = GetChar()
b[n] = b1
n:+1
Until b1 = 0
Return b
End Function
Function ConvertUnicode:String(str:Byte[], l:Int = -1, code:Int = 0) 'code for windows code page, 0 for system native
Global output:Short[2048]
MultiByteToWideChar(code, 0, str, l, output, 4096)
Return String.Fromwstring(output).Trim()
End Function
|