MCPcopy Index your code
hub / github.com/clips/pattern / decode_utf8

Function decode_utf8

pattern/web/imap/__init__.py:34–44  ·  view source on GitHub ↗

Returns the given string as a unicode string (if possible).

(string)

Source from the content-addressed store, hash-verified

32#### STRING FUNCTIONS ##############################################################################
33
34def decode_utf8(string):
35 """ Returns the given string as a unicode string (if possible).
36 """
37 if isinstance(string, str):
38 for encoding in (("utf-8",), ("windows-1252",), ("utf-8", "ignore")):
39 try:
40 return string.decode(*encoding)
41 except:
42 pass
43 return string
44 return unicode(string)
45
46def encode_utf8(string):
47 """ Returns the given string as a Python byte string (if possible).

Callers 14

wordsFunction · 0.85
stemFunction · 0.85
loadMethod · 0.85
exportMethod · 0.85
tableMethod · 0.85
cleanMethod · 0.85
nameMethod · 0.85
_parseMethod · 0.85
getMethod · 0.85
stringFunction · 0.85
loadMethod · 0.85
groupMethod · 0.85

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…