English 中文(简体)
如何读C#号的Ctxt文档中的Cyrillic符号
原标题:How to read Cyrillic symbols from a .txt file with C#

我看到了类似的议题,但找不到解决办法。 我的问题是,我有一口 file子,其符号是保加利亚语,即Cyrillic /,但在试图阅读这些标志之后,没有 su。 我尝试阅读这一法典:

StreamReader reader = new StreamReader(fileName,Encoding.UTF8);

if (File.Exists(fileName))
{
    while ((line = reader.ReadLine()) != null)
    {
        Console.WriteLine(line);
    }
}

我也把编码价值改为所有可能的编码价值,因为我与GetEncoding公司(1251)进行了尝试,我写道,这是cy。 当我拯救了txt案卷时,我试图用每条不同的编码来挽救它,而UNICODE、UTF-8、BigEndianUnicode、ANSI /在每种情况下都通过该法典编纂了我,但再次没有成功。

Any ideas for how to read the cyrillic symbols in the right way will be appriciated. And here is sample text for this: "Ето примерен текст."

提前感谢!

问题回答

你们的问题是,青少年能够展示cy。 在<代码>Console.WriteLine上打一个断点,并检查变量。 显然,你们需要首先了解正确的编码!

如果你不信任我的话,就会尝试:制定青少年方案,这样做:

string line = "Ето примерен текст"; 
Console.WriteLine(line);
return 0;

在<代码>return 0;上添加一个空白点,看着黄色并看线变量。

我要补充的是,单条编码综合体应当是“新”事物之一。

页: 1 缩略语

你们面临的问题不是阅读案文,而是展示。

如果你真的打算是把统法协会编码文本放在一个灯窗上,那么你就不得不作一些改动。 但是,如果你在温福或世界森林论坛的表象中显示案文,那么你就不会有问题——他们会不停地与统法协会合作。

缺席,议会将不处理统一编码,也不使用单一编码格体。 你们需要做以下工作:

  1. Save your text file as UTF8.
  2. Start a console which is unicode enabled: cmd u
  3. Change the font to "Lucida Sans Unicode": console window menu -> properties -> font
  4. Change the codepage to Unicode: chcp 65001
  5. Run your app.

你的特性现在将正确展示:

“entergraph





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签