Skip to content

Print currency and chars with accent #11

Open

Description

@lorenzoferrarajr

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!

Activity

  1. mcluseau commented on Apr 25, 2018

    @mcluseau
    Collaborator
  2. chaeusler commented on Oct 12, 2019

    @chaeusler

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions