pr0gramista / charset_converter

Flutter platform charset converter
BSD 3-Clause "New" or "Revised" License
33 stars 22 forks source link

Encode and decode problem #4

Closed danilof closed 4 years ago

danilof commented 4 years ago

@pr0gramista hi, thank you for this library. I also need to print windows1250 String on termal printer (slovenian language). But I have problem with encoding / decoding. This is example:

 String inputString = " čĆžŽšŠ-H-ščđ - in slovenian";
 Uint8List encodedBytes = await CharsetConverter.encode("windows1250", inputString);

//If I send this encodedBytes to printer - printer print correct characters

//But for formating output text on printer I need to send it as a String.

//And if I convert encodedBytes back to String and send it to printer the print characters are wrong:
String decoded = await CharsetConverter.decode("windows-1250", encodedBytes);

Can you please tell me what I am doing wrong here?

pr0gramista commented 4 years ago

Unfortunately converting it back to String won't work. I assue you are printing using ecs_pos_printer, if so you can try textEncoded on the Ticket class. Be sure to set the code page in PosStyles: codePage: "CP1250" or set it manually if your printer uses a bit different code tables.

Please let me know if that will help. I can check that myself tomorrow.

danilof commented 4 years ago

@pr0gramista Thnx. It works with textEncoded!