问题
How do I convert ISO-8859-6 to Arabic?
I have some encoded characters, e.g. ÇÎÊÈÇÑ. This is nothing but “Test” in English and اختبار in Arabic.
I want these characters as an input and Arabic as an output. To test further in Notepad++, try the following steps to get a better idea.
- Create New file and paste
ÇÎÊÈÇÑin it. - Go to encoding menu navigation -> Character Set -> Arabic -> ISO-8859-6/Windows-1256
It shows Arabic characters, which is nothing but “test” (Google Translator).
Actually, I want to replicate the reverse process, however I am unable to do same process L.
This is the code I'm trying:
byte[] utf8Bytes = Encoding.UTF8.GetBytes("ÇÎÊÈÇÑ");
System.Text.Encoding iso_8859_6 = System.Text.Encoding.GetEncoding("ISO-8859-6");
byte[] isoBytes = Encoding.Convert(Encoding.Unicode, iso_8859_6, utf8Bytes);
string unicodeconverted = Encoding.Unicode.GetString(isoBytes);
//string uf8converted = Encoding.UTF8.GetString(isoBytes);
回答1:
Quick conversion of a windows-1256 file to utf8:
string data = File.ReadAllText(path, Encoding.GetEncoding("windows-1256"));
File.WriteAllText(path, data, Encoding.UTF8);
来源:https://stackoverflow.com/questions/12448060/iso-8859-6-to-utf-8