Tag: encoding

在C#中没有UTF-32大端?

在C#中, Encoding.UTF32是UTF-32 little-endian, Encoding.BigEndianUnicode是UTF-16 big-endian, Encoding.Unicode是UTF-16 little-endian。 但我找不到UTF-32大端的任何东西。 我正在开发一个简单的textviewer,并且不认为有很多文档用UTF-32大端编码,但我也想为此做好准备,以防万一。 C#不支持UTF32大端吗? BTW Java支持它。

Encoding.Default如何在.NET中运行?

我正在使用以下方法读取文件: var source = File.ReadAllText(path); 并且字符©未正确加载。 然后,我将其更改为: var source = File.ReadAllText(path, Encoding.UTF8); 没别的了。 我决定尝试使用 var source = File.ReadAllText(path, Encoding.Default); 它工作得很好。 然后我调试它,并试图找到哪个编码做了伎俩,我发现它是UTF-7 。 我想知道的是: 是否建议使用Encoding.Default ,是否可以保证文件的所有字符都可以正常读取?

在C#字符串/字符编码中GetBytes(),GetString()和Convert()之间的区别是什么?

我们无法将Unicode字符串转换为UTF-8字符串以通过网络发送: // Start with our unicode string. string unicode = “Convert: \u10A0”; // Get an array of bytes representing the unicode string, two for each character. byte[] source = Encoding.Unicode.GetBytes(unicode); // Convert the Unicode bytes to UTF-8 representation. byte[] converted = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, source); // Now that we have converted the bytes, save them to […]