如何获取字符串的编码类型?
使用以下代码,我从流中获取一个字符串,但我不知道编码类型,因为它是由 StreamReader 自动检测到的;
如何获取字符串 respHTML 的编码类型?
Dim reader As StreamReader = New StreamReader(respStream, True)
Dim respHTML as String = reader.ReadToEnd()
With the following code, I get a string from a stream but I don't know the encoding type because it's detected automatically by StreamReader;
how can I get the encoding type of the string respHTML?
Dim reader As StreamReader = New StreamReader(respStream, True)
Dim respHTML as String = reader.ReadToEnd()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字符串包含 Unicode 字符,而不是字节。
编码是将 Unicode 字符保存为字节的方法;字符串没有任何编码。
您可以通过检查
CurrentEncoding
属性。Strings contain Unicode characters, not bytes.
Encodings are ways to save Unicode characters as bytes; a string doesn't have any encoding.
You can get the encoding used by the StreamReader by checking the
CurrentEncoding
property.