且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测文本文件的语言环境?

更新时间:2023-02-20 10:43:39

文本文件没有语言环境信息.文件之间的不同之处在于数据的编码.例如,可以使用ANSI或Unicode等保存一个简单的文本文件.
Text files don''t have locale information. What may differ between files is the encoding of the data. For example a simple text file can be saved using ANSI or Unicode etc.


整个语言环境已过时.语言环境的概念仍在Windows的不同版本中使用,大多以简陋的形式出现.如今,使用Unicode.

现在,文本文件可以具有UTF字节顺序标记(BOM),用于将使用 UTF 的信息告知文本编辑器.对于.NET API,文本流和阅读器类具有通过BOM自动识别Unicode UTF的选项.启用Unicode的文本编辑器具有另存为"选项,该选项允许选择UTF或不选择UTF,这意味着所有良好的ANSI.

有关更多详细信息,请参见:
http://unicode.org/ [ ^ ],
http://unicode.org/faq/utf_bom.html [
The whole idea of locale is obsolete. A notion of locale is still used in different version of Windows, mostly in the form of rudiment. These days, Unicode is used.

Now, the text files can have a UTF Byte-Order Marker (BOM) used to inform a text editor on what UTF is used. As to .NET API, text stream and reader classes have options to auto-recognize Unicode UTFs by the BOM. Unicode-enabled text editors have the "Save as" option which allows to select the UTF or none, which means all good ANSI.

For further detail, see:
http://unicode.org/[^],
http://unicode.org/faq/utf_bom.html[^].

—SA


现在我的文本文件来自希腊语,当我读取该文件时,出现问题说格式无效,无法读取".我至少应该如何读取此文件,然后我可以做
value.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
进行转换.
Now my text file from greek, when I read this file in, it has problem said "has invalid formatting and can not be read". How can I read this file in at least, then I can do
value.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
to convert it.