How to open Arabic text file with correct encoding in Visual Studio

耗尽温柔 提交于 2021-02-10 06:07:16

问题


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 desperately need to read this arabic text as this is the only back up we have

Thanks


回答1:


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




回答2:


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);


来源:https://stackoverflow.com/questions/6828148/how-to-open-arabic-text-file-with-correct-encoding-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!