in one of my X# applications I'm interfacing a web service with my ADS and DBF based ERP system.
To read and write to ADS (Advantage Database Server) I'm not using the RDD, but the Advantage.Data.Provider.DLL that works very well, even using joins.
But sometimes the webservice returns me UTF8 strings, and using them in a SQL update statement returns the following error:
Code: Select all
Error 7200: AQE Error: State = HY000; NativeError = 5211; [iAnywhere Solutions][Advantage SQL][ASA] Error 5211: There is an error converting Unicode string to or from code page string. Some Unicode characters cannot be converted to code page characters. AdsCommand query execution failed.
Now I need to change the characters in that string to translate the not convertible characters to others that can be translated by ADS. I'm perfectly conscius that there will be lost some information, but I prefer to have incomplete information.
I have now tried this code:
Code: Select all
static method FixAnsi( cString as string ) as string
local cReturn as string
local oUnicode as System.Text.Encoding
local oAnsi1252 as System.Text.Encoding
oUnicode := System.Text.Encoding.Unicode
oAnsi1252 := System.Text.Encoding.GetEncoding( 1252 )
cReturn := oAnsi1252:GetString( System.Text.Encoding.Convert( oUnicode, oAnsi1252, oUnicode:GetBytes( cString ) ) )
return cReturn
Has someone an idea what I could do?
Wolfgang