MCPcopy Create free account
hub / github.com/ActiveState/code / encode

Method encode

recipes/Python/252124_LaTeX_codec/recipe-252124.py:45–59  ·  view source on GitHub ↗

Convert unicode string to latex.

(self,input,errors='strict')

Source from the content-addressed store, hash-verified

43
44 class Codec(codecs.Codec):
45 def encode(self,input,errors='strict'):
46 """Convert unicode string to latex."""
47 output = []
48 for c in input:
49 if encoding:
50 try:
51 output.append(c.encode(encoding))
52 continue
53 except:
54 pass
55 if ord(c) in latex_equivalents:
56 output.append(latex_equivalents[ord(c)])
57 else:
58 output += ['{\\char', str(ord(c)), '}']
59 return ''.join(output), len(input)
60
61 def decode(self,input,errors='strict'):
62 """Convert latex source string to unicode."""

Callers 15

cjkwrapFunction · 0.45
charactersMethod · 0.45
encode_for_xmlFunction · 0.45
_xmlcharref_encodeFunction · 0.45
StartElementMethod · 0.45
CharacterDataMethod · 0.45
_quoteMethod · 0.45
_run_child_withencodingFunction · 0.45
recipe-67083.pyFile · 0.45
setDataMethod · 0.45
startElementMethod · 0.45
charactersMethod · 0.45

Calls 3

strFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected