I hope i didn´t overlook something, but IMO, to be compatible with VO, Chr() and Asc() should behave as ChrA() and AscA()
Code: Select all
_DLL FUNCTION MessageBox(hwnd AS intptr , lpText AS STRING, lpCaption AS STRING, uType AS DWORD);
AS INT PASCAL:USER32.MessageBoxA ANSI
//#define _USE_ASC_CHR_
FUNCTION Start() AS VOID
LOCAL c, cResult AS STRING
LOCAL i AS DWORD
c := Ansi2Oem ( "Ärger" )
messagebox ( NULL , "Result: " + c + chr(13) + chr(10) +;
"Should be: " + "Žrger" , "" , 0 ) // ok
cResult := ""
FOR i := 1 TO SLen ( c )
#ifdef _USE_ASC_CHR_
cResult := cResult + NTrim(Asc( SubStr (c , i , 1 ) ) ) + " "
#else
cResult := cResult + NTrim(AscA( SubStr (c , i , 1 ) ) ) + " "
#endif
NEXT
#ifdef _USE_ASC_CHR_
messagebox ( NULL , c + chr(13) + chr(10) + cResult + chr(13) + chr(10) + CHR ( 90 ) , "" , 0 )
// "Žrger"
// 90 114 103 101 114
// "Z"
#else
messagebox ( NULL , c + chr(13) + chr(10) + cResult + chr(13) + chr(10) + CHRA ( 142 ) , "" , 0 ) // 8E
// VO shows the same results "codepage 1252" 142 == "Ž"
// "Žrger"
// 142 114 103 101 114
// "Ž"
#endif
c := "Ärger"
cResult := ""
FOR i := 1 TO SLen ( c )
#ifdef _USE_ASC_CHR_
cResult := cResult + NTrim(Asc ( SubStr (c , i , 1 ) ) ) + " "
#else
cResult := cResult + NTrim(AscA ( SubStr (c , i , 1 ) ) ) + " "
#endif
NEXT
#ifdef _USE_ASC_CHR_
messagebox ( NULL , c + chr(13) + chr(10) + cResult + chr(13)+chr(10) + CHR ( 142 ) , "" , 0 )
// "Ärger"
// 142 114 103 101 114
// "?"
#else
messagebox ( NULL , c + chr(13) + chr(10) + cResult + chr(13)+chr(10) + CHRA ( 196 ) , "" , 0 ) // C4
// VO shows the same results "codepage 1252" 196 == "Ä"
// "Ärger"
// 196 114 103 101 114
// "Ä"
#endif
RETURN
Karl-Heinz