我試圖將這個字符串的編碼從utf-8轉換爲ukranian「ÐÑайвÐμÑ-Ð'лÑ-пÑинÑÐμÑа-Pixma-ip- 2000Ð'лN-Windows的7-64-d±DN」。 每當我把它轉換從UTF8到烏克蘭,我收到了損壞的串...C# - 將UTF-8轉換爲烏克蘭編碼
正確的字符串應該像 「Драйвер-для-принтера - 佳能PIXMA-IP-2000-для-Windows的7-64-бит」 ..
請指教..謝謝
編輯:這裏是如何轉換我吧..
private string EncodeUTF8toOther(string inputString, string to)
{
try
{
// Create two different encodings.
byte[] myBytes = Encoding.Unicode.GetBytes(inputString);
// Perform the conversion from one encoding to the other.
byte[] convertedBytes = Encoding.Convert(Encoding.Unicode, Encoding.GetEncoding(to), myBytes);
return Encoding.GetEncoding("ISO-8859-1").GetString(convertedBytes);
}
catch
{
return inputString;
}
}
烏克蘭字符集是 「KOI8-U」
更多信息:我有這個問題的類似問題: c# HttpWebResponse Header encoding
位置標題是給我這個損壞的字符串。我需要正確編碼才能執行重定向。
你是如何轉換它? –
你的字符串看起來像「免打擾°Ð¹Ð²Ðμ......」從一開始?然後它已經損壞。 – deceze
發佈更新..請檢查它。 – SolidSnake