开发者

How to convert the encoding type of a stream in .NET?

开发者 https://www.devze.com 2023-02-01 14:16 出处:网络
I ve the following stream but I don\'t know its encoding type because the stream reader detects encoding from byte order marks

I ve the following stream but I don't know its encoding type because the stream reader detects encoding from byte order marks

Dim reader As StreamReader = New StreamReader(respStream, True) 

so开发者_如何转开发 how can I detect the encoding type AND convert it to another type? (for ex. from ASCII to UTF8)

PS:

What is the difference with the following line?

Dim reader As StreamReader = New StreamReader(respStream,

Encoding.ASCII, True)

Thank You in advance,

Max


You can check the StreamReader's CurrentEncoding property, and you can write the string to a StreamWriter with a different Encoding.

To answer your unrelated question, that explicitly specifies the encoding.

0

精彩评论

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