Encoding.GetEncoding(1255) 和 Encoding.GetEncoding(1252) 有什么区别?
我有一个基于 C# 表单的程序,并且一直在使用
System.Text.Encoding.GetEncoding(1252)
但我在读取非英语字符时遇到了问题,我发现了
System.Text .Encoding.GetEncoding(1255)
有效,但我不知道更改此设置的含义,因此我希望有人能够阐明其中的差异和可能的含义。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
当您使用 GetEncoding(1252) 时,您指定的是 Windows-1252 编码,指定西欧的拉丁字母。 GetEncoding(1255) 是 Windows-1255 编码,用于书写希伯来语。
When you use GetEncoding(1252), you're specifying the Windows-1252 Encoding, which specifies a latin alphabet for Western Europe. GetEncoding(1255) is the Windows-1255 encoding, which is used to write Hebrew.
字符编码 1255 包括希伯来语符号,而 1252 则面向西方语言。难道非英语符号恰好是希伯来语吗?
Character encoding 1255 includes Hebrew symbols whereas 1252 is geared towards Western Languages. Is it the case that the non-English symbols happen to be Hebrew?
1252 是 Windows-1252 西欧 (Windows)
1255 是 Windows-1255 希伯来语 (Windows)
来源:http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.codepage.aspx
1252 is Windows-1252 Western European (Windows)
1255 is Windows-1255 Hebrew (Windows)
source: http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.codepage.aspx
您的编码应始终与用于创建文件的编码相匹配。如果没有可用的元数据(或人员)来指导此选择,那么唯一要做的就是尝试每个元数据,看看哪个是清晰的。由于这显然是您不懂的语言,因此您可能需要询问说该语言的人是否清晰。你认识能读希伯来语的人吗?
Your encoding should always match the one that was used to create the file. If there is no metadata (or person) available to guide this selection, then the only thing to do would be to try each one and see which is legible. Since this is apparently in a language that you don't know, you may need to ask someone who speaks the language if it's legible. Do you know anyone who can read Hebrew?
您可能想要使用“命名”Unicode 编码之一,例如
编码.UTF8
。但是,回答你的问题 - 第 1252 页是“西欧( Windows)”,1255 是“希伯来语 (Windows)”。如果您不知道,代码页几乎就是 ,您应该尽可能坚持使用 Unicode。
You probably want to use one of the "named" Unicode encodings, eg.,
Encoding.UTF8
. But, to answer your question - page 1252 is "Western European (Windows)" and 1255 is "Hebrew (Windows)".If you're not aware, code pages are pretty much a relic of ASCII and you should try to stick with Unicode where possible.