开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜