9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet

Home Page:http://www.nugetmusthaves.com/Package/Telnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sending UTF-8 characters in XML file

GustavJansson11 opened this issue · comments

Hello!

I'm making a C# Application that is using this Telnet NuGet and it works great except for one thing, I can't send swedish special characters (ÅÄÖ) which is in the UTF-8 encoding.

When i send my XML file (that contains ÅÄÖ) over the client with:

await cli.Write(System.IO.File.ReadAllText("myXMLFILE.xml"));

All my ÅÄÖ:s are converted to questions marks so for example "Bäst" becomes "B?st".

Is there any way to change the encoding so that the Telnet client doesn't convert my special characters?

Best regards

Try

var buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(command.Replace("\0xFF", "\0xFF\0xFF"));

Thank you very much! I changed the line slightly in order for it to work with my type of characters but after doing that, It worked! Thanks!

The code i used:

String s = the string that contains ÅÄÖ 
var buffer = Encoding.UTF8.GetBytes(s.Replace("\0xFF", "\0xFF\0xFF"));
await cli.Write(buffer);

You're welcome. Glad it's been helpful.