escpos icon indicating copy to clipboard operation
escpos copied to clipboard

Print currency and chars with accent

Open lorenzoferrarajr opened this issue 6 years ago • 2 comments

Hi, I don't understand how to print currency symbols, like , and chars with accent, like è.

I'm trying this:

p.SetLang("it")
p.Write("èéà°òçù§£$€")

but all I get is scrambled text.

Thanks for your work!

lorenzoferrarajr avatar Apr 25 '18 13:04 lorenzoferrarajr

Hi,Probably a charger issue. Did you try to send raw char for € in say ISO 8859-15 "\xa4"?Le 26 avr. 2018 00:23, Lorenzo Junior Ferrara [email protected] a écrit :Hi, I don't understand how to print currency symbols, like €, and chars with accent, like è. I'm trying this: p.SetLang("it") p.Write("èéà°òçù§£$€")

but all I get is scrambled text. Thanks for your work!

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

mcluseau avatar Apr 25 '18 19:04 mcluseau

You need to encode your characters to the desired format before calling 'p.Write'.

i.e.:

import "golang.org/x/text/encoding/charmap"

// omitted code ...

text := "èéà°òçù§£$€"
encoder := charmap.CodePage437.NewEncoder()
encoded, _ := encoder.String(text)
p.Write(encoded)

Go doc: https://godoc.org/golang.org/x/text/encoding/charmap Used code page: https://reference.epson-biz.com/modules/ref_charcode_en/

chaeusler avatar Oct 12 '19 12:10 chaeusler