If you're like me where you are maintaining libraries for DF19 and DF20 - then these routines would be valuable.
Anywhere you're using :
1. ToANSI can be swapped with NativeToWinStr
2. ToOEM can be swapped with WinStrToNative
This will make the string conversions compatible in both DF19 and DF20
Just save to the following as a pkg file.
Code:
Use GlobalFunctionsProcedures.pkg
// alias data-types.
#IF (!@ < 200)
Define WString for String
// #Replace WString String // used for DF20 Unicode
#ENDIF
{ Description="Converts DataFlex String to Windows ANSI/UTF8 String" }
Function ToCString Global String sStr Returns String
If (Length(sStr)=0) Move (Character(0)) to sStr
Else Begin
If (not(Ascii(Right(sStr,1))=0)) Append sStr (Character(0))
#IF (!@ < 200)
Move (ToANSI(sStr)) to sStr
#ENDIF
End
Function_Return sStr
End_Function
{ Description="Converts Windows ANSI/UTF8 to DataFlex String" }
Function WinStrToNative Global String sStr Returns String
#IF (!@ < 200)
Move (ToOEM(sStr)) to sStr
#ENDIF
Function_Return (CString(sStr))
End_Function
{ Description="Converts DataFlex String to Windows ANSI/UTF8 String" }
Function NativeToWinStr Global String sStr Returns String
Function_Return (ToCString(sStr))
End_Function