开发者

Is there a way to detect the encoding of a stream in vb.net?

开发者 https://www.devze.com 2023-04-03 03:44 出处:网络
I would like to know the way a stream or a string is encoded before converting it. If a string is not utf-8 i开发者_如何学Ct would be converted to utf-8. You could use the WinAPI function IsTextUnicod

I would like to know the way a stream or a string is encoded before converting it. If a string is not utf-8 i开发者_如何学Ct would be converted to utf-8.


You could use the WinAPI function IsTextUnicode which uses a heuristic to guess the proper encoding. Note that this can go hilariously wrong.

The best way is not to accept streams without external information about their encoding, and failing that, internal information (such as a BOM, or a HTML meta-tag with encoding information).

0

精彩评论

暂无评论...
验证码 换一张
取 消