printing - C# ESC POS Special characters -


i'm making class esc pos printing.

it needs support special norwegian characters: ÆØÅæøå

the problem can't use them in string.

"data print: ÆØÅæøå" print "data print: ??????"

according documentation these chars prints special characters need:

(char)91 prints "Æ"

(char)92 prints "Ø"

(char)93 prints "Å"

(char)123 prints "æ"

(char)124 prints "ø"

(char)125 prints "å"

so question is: there better way replace each of characters?

here code connects printer , sends data:

        socket clientsock = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp);         clientsock.nodelay = true;         ipaddress ip = ipaddress.parse("192.168.0.11");         ipendpoint remoteep = new ipendpoint(ip, 9100);         clientsock.connect(remoteep);         byte[] bydata = encoding.ascii.getbytes(buffer);         clientsock.send(bydata);         clientsock.close(); 

solved:

encoding nordic = encoding.getencoding("ibm865"); byte[] bydata = nordic.getbytes(buffer); 

if standard codepage (like code page 865 nordic languages), can use appropriate encoding:

encoding nordic = encoding.getencoding("ibm865");  

check supported encodings encoding class see if there match. character layout of 865, looks need replace characters yourself.

you can create characters mappings using dictionary, large switch/case statement fine start (you can refactor if ever need 1 day).


Comments