Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top