Daniel Steele
Daniel Steele

Reputation: 33

Screamwriter outputting to Vietnamese, not ASCII (English)

In a nutshell, creating a ASCII text file that records polling data from a printer under test. The expected output should be US English, but the text file is in Vietnamese. Example: the_Maker = "Epson", SubModel = "T88V", serial_num = PD9F393594, error_list = total # of polling errors (a number). - Example if testing a Epson T88V Thermal Printer.

using (System.IO.StreamWriter file = new System.IO.StreamWriter(output_file, true))                
{
    ASCIIEncoding ascii = new ASCIIEncoding();
    file.WriteLine(the_Maker + " ● " + SubModel + " ● " + serial_num + " ● " + error_list + " END Polls " + DateTime.Now.ToString());
}

Output from file: 偅体辗䵔吭㠸辗䑐䘹㤳㔳㐹韢䖏䑎倠汯獬㔠㈯⼷〲㤱㔠㌺㨶㈵倠്䔊卐乏辗吠ⵍ㡔嘸辗倠㥄㍆㌹㤵‴韢₏䔠䑎倠汯獬㔠㈯⼷〲㤱㔠㌺㨸㘲倠്

This should be in English

Upvotes: -2

Views: 117

Answers (1)

vinicius.ras
vinicius.ras

Reputation: 1596

If you intend to use an encoding for the StreamWriter, you have to construct the StreamWriter with the target encoding. You are currently creating an ASCIIEncoding object and not using it.

ASCIIEncoding ascii = new ASCIIEncoding();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(output_file, true, ascii))                
{
    file.WriteLine(the_Maker + " ● " + SubModel + " ● " + serial_num + " ● " + error_list + " END Polls " + DateTime.Now.ToString());
}

Upvotes: 0

Related Questions