udfCodepageConvert
str udfCodepageConvert (str, int, int)
#DefineFunction udfCodepageConvert (strTextFrom, intCpFrom, intCpTo)
intPrevCodepage = ChrSetCodepage (intCpFrom)
strUnicode = ChrStringToUnicode (strTextFrom)
ChrSetCodepage (intCpTo)
strTextTo = ChrUnicodeToString (strUnicode)
ChrSetCodepage (intPrevCodepage)
Return strTextTo
; (c)Detlev Dalitz.20100220.
#EndFunction


;Test.

intCpFrom = 850
intCpTo = 1252

strTextFrom = ""
For intN = 128 To 255
   strTextFrom = strTextFrom : Num2Char (intN)
Next
strTextTo = udfCodepageConvert (strTextFrom, intCpFrom, intCpTo)

strMsgTitle = "Codepage conversion from " : intCpFrom : " to " : intCpTo : " (upper half of the codepage set, characters 128..255)"
strMsgText = "Cp" : intCpFrom : @LF : strTextFrom : @LF : @LF : "Cp" : intCpTo : @LF : strTextTo : @LF : @LF : "Note: This is the Message Box ANSI view to the characters!"
Pause (strMsgTitle, strMsgText)


strTextFrom = "Gltigkeitsbereich von Žnderungen. ... ursprngliche Einstellungen mssen ausgefhrt werden ... fr alle Befehle ge„ndert."
strTextTo = udfCodepageConvert (strTextFrom, intCpFrom, intCpTo)

strMsgTitle = "Codepage conversion from " : intCpFrom : " to " : intCpTo : " (example string)"
strMsgText = "Cp" : intCpFrom : @LF : strTextFrom : @LF : @LF : "Cp" : intCpTo : @LF : strTextTo : @LF : @LF : "Note: This is the Message Box ANSI view to the characters!"
Pause (strMsgTitle, strMsgText)

:CANCEL
Exit