I get from some dll library (which is a wrapper for some external data sources) in the Windows-1250 code page, and I would like to insert them correctly (as unicode) into a table in a SQL Server database. Since a specific row in the database that should contain this data of type NVarchar, I needed to convert it to C # code in unicode and pass it as a parameter. Everything is good and pleasant, but I came across a transition step.
I tried the following, but this does not work:
private static String getUnicodeValue(string string2Encode)
{
Encoding srcEncoding = Encoding.GetEncoding("Windows-1250");
UnicodeEncoding dstEncoding = new UnicodeEncoding();
byte[] srcBytes = srcEncoding.GetBytes(string2Encode);
byte[] dstBytes = dstEncoding.GetBytes(string2Encode);
return dstEncoding.GetString(dstBytes);
}
When I insert this returned row into the table, I do not receive the correct letters, such as Đ, đ, Č, č, Ć or ć.
Please, help!:)
source
share