I use below code for convert UTF8 (Persian characters) to LATIN1.
but it doesn't work for some character like (و ی ه)
Encoding iso = Encoding.GetEncoding("ISO-8859-1");
Encoding utf8 = Encoding.UTF8;
byte[] utfBytes = utf8.GetBytes(source);
string des = iso.GetString(utfBytes);
I use below code for convert UTF8 (Persian characters) to LATIN1.
ISO-8859-1 cannot contain Persian characters. What you are doing is intentionally making a mojibake error.
If your code is doing something functional, that implies that there is some other component taking the output from des
and handling it incorrectly (ie outputting it as a Latin-like encoding when it should originally have been using UTF-8). If you can at all, it would be much better to fix that problem downstream, instead of trying to work around it with deliberately-bad encoding.
If you really have to handle it this way, and some characters work but others don't, the likelihood is that Latin-like encoding you are trying to target is not actually real Latin-1 (ISO-8859-1); the most likely reason for that is that it is Windows code page 1252. This shares many of the same character mappings as ISO-8859-1, but not all. So try GetEncoding(1252)
.