1 | #include <WinAPIConv.au3> |
---|
2 | |
---|
3 | ;~ Global Const $CP = 0 ; CP_ACP default copepage |
---|
4 | ;~ Global Const $CP = GetACP() ; current codeoage |
---|
5 | ;~ Global Const $CP = 65001 ; UTF-8 certainly the best value |
---|
6 | Global Const $CP = 65001 ; CP_SHIFT_JIS |
---|
7 | |
---|
8 | Local $sText = 0x99c599c5 |
---|
9 | $a = BinaryToString($sText,4) |
---|
10 | ConsoleWrite(StringLen($a)) |
---|
11 | FileWrite("wkdfb.txt",$a) |
---|
12 | MsgBox(0,"",$a) |
---|
13 | Exit |
---|
14 | Local $sOutput = @TAB & @TAB & "Copepage =" & $CP & @CRLF & @CRLF |
---|
15 | $sOutput &= @TAB & "String[" & StringLen($sText) & "] = " & $sText & @CRLF & @CRLF |
---|
16 | |
---|
17 | ; ============== _WinAPI_WideCharToMultiByte Test ============== |
---|
18 | |
---|
19 | Local $sTest = _WinAPI_WideCharToMultiByte($sText, $CP, True, False) |
---|
20 | $sOutput &= "WideChar to String (MultiByte)" & @TAB & VarGetType($sTest) & " " & StringLen($sTest) & " :" & @CRLF & $sTest & @CRLF & @CRLF |
---|
21 | |
---|
22 | $sTest = _WinAPI_WideCharToMultiByte($sText, $CP, True, True) |
---|
23 | $sOutput &= "WideChar to Binary" & @TAB & VarGetType($sTest) & " " & BinaryLen($sTest) & " :" & @CRLF & $sTest & @CRLF & @CRLF |
---|
24 | |
---|
25 | ; ============== _WinAPI_MultiByteToWideChar Test ============== |
---|
26 | |
---|
27 | Local $sMultiByte = _WinAPI_WideCharToMultiByte($sText, $CP, True, False) |
---|
28 | $sOutput &= @CRLF & @TAB & "MultiByte[" & StringLen($sMultiByte) & "] = " & $sMultiByte & @CRLF & @CRLF |
---|
29 | |
---|
30 | Local $tStruct = _WinAPI_MultiByteToWideChar($sMultiByte, $CP, 0, False) |
---|
31 | $sOutput &= "MultiByte to Struct" & @TAB & @TAB & VarGetType($tStruct) & " " & DllStructGetSize($tStruct) & " :" & @CRLF & DllStructGetData($tStruct, 1) & @CRLF & @CRLF |
---|
32 | |
---|
33 | $sTest = _WinAPI_MultiByteToWideChar($sMultiByte, $CP, 0, True) |
---|
34 | $sOutput &= "MultiByte to String" & @TAB & VarGetType($sTest) & " " & StringLen($sTest) & " :" & @CRLF & $sTest & @CRLF & @CRLF |
---|
35 | |
---|
36 | Local $iMB_TYPE = 0 |
---|
37 | If $sTest == $sText Then |
---|
38 | $sOutput &= @CRLF & @TAB & @TAB & "Conversion OK" |
---|
39 | Else |
---|
40 | $sOutput &= @CRLF & @TAB & @TAB & " !!! Erreur de Conversion !!!" |
---|
41 | $iMB_TYPE = $MB_ICONERROR |
---|
42 | EndIf |
---|
43 | |
---|
44 | MsgBox($MB_SYSTEMMODAL + $iMB_TYPE, "Results", $sOutput) |
---|
45 | |
---|
46 | Func GetACP() |
---|
47 | Local $aResult = DllCall("kernel32.dll", "int", "GetACP") |
---|
48 | If @error Or Not $aResult[0] Then Return SetError(@error + 20, @extended, "") |
---|
49 | Return $aResult[0] |
---|
50 | EndFunc ;==>GetACP |
---|