I can not apply Encoder in the text to correctly appear "ç, accents, other special characters"

0

Hello,

I need to collect information from the station, and I'm getting it. But in the received text I can not apply an Encoder to appear the special characters correctly:

I'vetriedusing"ISO-8859-1", and other forms of encode too

string blah = System.Text.Encoding.Unicode.GetString(System.Text.Encoding.Unicode.GetBytes(suaString));

or

byte[] bytes = Encoding.Default.GetBytes(sOutput);
sOutput = Encoding.UTF8.GetString(bytes);
var teste = Encoding.UTF8.GetString(bytes);
    
asked by anonymous 28.04.2017 / 19:25

2 answers

0

To get around the difficulty I picked up the characters that were coming and made replace by the equivalent characters:

sOutput = sOutput.Replace('?', 'ç').Replace('Æ', 'ã').Replace('¢', 'ó').Replace('¡', 'í').Replace("Portuguçs","Português");
    
18.05.2017 / 22:08
1

I made an application here and rode on a Windows 10 machine in Portuguese and another one with windows 10 in English, and on both machines I got the same result.

When I just did the line below:

string sOutput = CurrentProcess.StandardOutput.ReadToEnd();

The encoding was correct, however when I ran

Encoding iso = Encoding.GetEncoding("us-ascii");
Encoding utf8 = Encoding.UTF8;
byte[] utfBytes = utf8.GetBytes(sOutput);
byte[] isoBytes = Encoding.Convert(utf8, iso, utfBytes);
sOutput = iso.GetString(isoBytes);

The same problem you're having happened.

I mean, I do not see the need for you to do the conversions.

    
28.04.2017 / 21:57