Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print currency and chars with accent #11

Open
lorenzoferrarajr opened this issue Apr 25, 2018 · 2 comments
Open

Print currency and chars with accent #11

lorenzoferrarajr opened this issue Apr 25, 2018 · 2 comments

Comments

@lorenzoferrarajr
Copy link

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!

@mcluseau
Copy link
Collaborator

mcluseau commented Apr 25, 2018 via email

@chaeusler
Copy link

chaeusler commented Oct 12, 2019

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants