9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet
http://www.nugetmusthaves.com/Package/Telnet
MIT License
126 stars 50 forks source link

How to read UTF8 strings? #74

Open m1dst opened 1 year ago

m1dst commented 1 year ago

Is there a way I can read UTF8 stings? The data I am receiving contains German characters and they appear to be corrupted. Likely being converted to ASCII. Is there a setting or a special method I need to use?

9swampy commented 1 year ago

Afraid not, out of the box; https://github.com/9swampy/Telnet/blob/develop/PrimS.Telnet.NetStandard/ByteStringConverter.cs

Swap that out or handle the bytestream yourself. If you make it more flexible I'd be happy to accept a PR :)

m1dst commented 1 year ago

Look at the source, I don't think it is as easy as just swapping out ByteStringConverter. It looks like the read routines process the data one byte at a time. UTF8 characters are never going to be single bytes. They are probably 2 but could be more.

I think it is RetrieveAndParseResponse which processes the response stream and that is what would need to be changed. Not really sure how this can be changed without breaking what you have already.