MCPcopy Create free account
hub / github.com/catboost/catboost / to_str

Function to_str

library/python/strings/strings.py:57–65  ·  view source on GitHub ↗
(value, to_enc=DEFAULT_ENCODING, from_enc=None)

Source from the content-addressed store, hash-verified

55
56# Optional from_enc enables transcoding
57def to_str(value, to_enc=DEFAULT_ENCODING, from_enc=None):
58 if isinstance(value, six.binary_type):
59 if from_enc is None or to_enc == from_enc:
60 # Unknown input encoding or input and output encoding are the same
61 return value
62 value = to_unicode(value, from_enc=from_enc)
63 if isinstance(value, six.text_type):
64 return value.encode(to_enc, ENCODING_ERRORS_POLICY)
65 return six.binary_type(value)
66
67
68def _convert_deep(x, enc, convert, relaxed=True):

Callers

nothing calls this directly

Calls 3

isinstanceFunction · 0.85
to_unicodeFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected