Forcinge the codepage of a file so that it can show characters encoded with windows-1256 correctly?

StackOverflow https://stackoverflow.com/questions/19021824

Domanda

I need to save a plain text file with Arabic characters in it, and Arabic characters must be appear as Arabic when the file will be opened.

I can insert the names without problem using Encoding.GetEncoding(1256) and save the file - again using 1256 as the StreamWriter's codepage.

However, when viewing the resulting file in Notepad++ the characters do not appear correctly and I have to deliberately switch the codepage back to 1256 for them to appear in Arabic.

I am then transmitting the file to a third party, but they cannot change the codepage (I have no idea why!) and therefore cannot read the Arabic.

Is there any way I can save the file so that the codepage to be used is "embedded" in the file?

È stato utile?

Soluzione

Save the file as UTF-8. That should automatically include a magic BOM (Byte Order Mark) in the beginning of the file so applications opening the file will know it is encoded in UTF-8.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top