Skip to content

How does FontTools decode byte-strings in name table? #2638

Answered by behdad
http403 asked this question in Q&A
Discussion options

You must be logged in to vote

def toUnicode(self, errors='strict'):
"""
If self.string is a Unicode string, return it; otherwise try decoding the
bytes in self.string to a Unicode string using the encoding of this
entry as returned by self.getEncoding(); Note that self.getEncoding()
returns 'ascii' if the encoding is unknown to the library.
Certain heuristics are performed to recover data from bytes that are
ill-formed in the chosen encoding, or that otherwise look misencoded
(mostly around bad UTF-16BE encoded bytes, or bytes that look like UTF-16BE
but marked otherwise).…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@http403
Comment options

Answer selected by http403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants