How to open Arabic text file with correct encoding in Visual Studio
I have a C# file that has some arabic text in it, I got the file from another source, the arabic text is now scrambled. looking like this ("ÇáãæÇÞÚ ÇáÞÇÈáÉ ááÊØæíÑ ÇáÓíÇÍì"), I tried to save the file in another encoding (UTF-8) but still same result, I d开发者_JAVA百科esperately need to read this arabic text as this is the only back up we have
Thanks
Try right-clicking the file in VS solution explorer, then choose:
Open With... -> CSharp Editor with Encoding
This should force VS to read the file with a unicode encoding, rather than as single byte text.
Although you are saving in UTF-8
, the file may be missing the Byte Order Mark (BOM)
for UTF-8
at the beginning of the file. A BOM
for UTF-8
files is optional.
Update
If the file has no BOM
, try:
... CSharp Editor with Encoding -> Unicode (UTF-8 without signature) codepage 65001
Update
The file is not unicode encoded, it requires opening with an Arabic codepage. Try opening as follows, or with one of the other Arabic codepages:
... CSharp Editor with Encoding -> Arabic (864) - Codepage 864
use the following code if you want to load or save to file using rtb text without streams:
saveFile.ShowDialog();
rtbText.SaveFile(saveFile.FileName,RichTextBoxStreamType.PlainText);
openFile.ShowDialog();
rtbText.LoadFile(openFile.FileName,RichTextBoxStreamType.PlainText);
精彩评论