Guest User

mbstowcs/wcstombs

a guest
Dec 10th, 2011
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include once "windows.bi"
  3. #include once "crt/stdlib.bi"
  4.  
  5. extern "c"
  6. declare function setlocale (byval as integer, byval as zstring ptr) as zstring ptr
  7. end extern
  8.  
  9. declare function MessageBoxA alias "MessageBoxA" (byval as HWND, byval as LPCSTR, byval as LPCSTR, byval as UINT) as integer
  10. declare function MessageBoxW alias "MessageBoxW" (byval as HWND, byval as LPCWSTR, byval as LPCWSTR, byval as UINT) as integer
  11.  
  12. dim texta as string * 100 = "ハローワールド"
  13. dim textw as wstring * 100 = ""
  14.  
  15. setlocale(0, "jpn")
  16.  
  17. 'マルチバイトからワイドに変換
  18. mbstowcs(@textw, texta, 100)
  19.  
  20. MessageBoxA( 0, texta, 0, 0 )
  21. MessageBoxW( 0, textw, 0, 0 )
  22.  
  23. 'ワイドからマルチバイトに変換
  24. wcstombs(texta, @textw, 100 )
  25.  
  26. MessageBoxA( 0, texta, 0, 0 )
  27. MessageBoxW( 0, textw, 0, 0 )
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment