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

Class EncodedString

contrib/tools/cython/Cython/Compiler/StringEncoding.py:100–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99
100class EncodedString(str):
101 # unicode string subclass to keep track of the original encoding.
102 # 'encoding' is None for unicode strings and the source encoding
103 # otherwise
104 encoding = None
105
106 def __deepcopy__(self, memo):
107 return self
108
109 def byteencode(self):
110 assert self.encoding is not None
111 return self.encode(self.encoding)
112
113 def utf8encode(self):
114 assert self.encoding is None
115 return self.encode("UTF-8")
116
117 @property
118 def is_unicode(self):
119 return self.encoding is None
120
121 def contains_surrogates(self):
122 return string_contains_surrogates(self)
123
124 def as_utf8_string(self):
125 return bytes_literal(self.utf8encode(), 'utf8')
126
127 def as_c_string_literal(self):
128 # first encodes the string then produces a c string literal
129 if self.encoding is None:
130 s = self.as_utf8_string()
131 else:
132 s = bytes_literal(self.byteencode(), self.encoding)
133 return s.as_c_string_literal()
134
135
136def string_contains_surrogates(ustring):

Callers 15

generate_shared_moduleFunction · 0.90
visit_ModuleNodeMethod · 0.85
add_testMethod · 0.85
visit_AssertStatNodeMethod · 0.85
visit_WithStatNodeMethod · 0.85
_handle_ExprNodeMethod · 0.85
DecoratorTransformClass · 0.85
_add_propertyMethod · 0.85
_set_qualnameMethod · 0.85
generate_assignmentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected