本文整理汇总了Python中pypy.objspace.std.unicodetype.unicode_from_string函数的典型用法代码示例。如果您正苦于以下问题:Python unicode_from_string函数的具体用法?Python unicode_from_string怎么用?Python unicode_from_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unicode_from_string函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add__Unicode_String
def add__Unicode_String(space, w_left, w_right):
# this function is needed to make 'abc'.__radd__(u'def') return
# u'defabc', although it's completely unclear if that's necessary
# given that CPython doesn't even have a method str.__radd__().
from pypy.objspace.std.unicodetype import unicode_from_string
return space.add(w_left, unicode_from_string(space, w_right))
示例2: unicode_w
def unicode_w(w_self, space):
# Use the default encoding.
from pypy.objspace.std.unicodetype import (unicode_from_string,
decode_object, _get_encoding_and_errors)
w_defaultencoding = space.call_function(space.sys.get(
'getdefaultencoding'))
encoding, errors = _get_encoding_and_errors(space, w_defaultencoding,
space.w_None)
if encoding is None and errors is None:
return space.unicode_w(unicode_from_string(space, w_self))
return space.unicode_w(decode_object(space, w_self, encoding, errors))
示例3: add__String_Unicode
def add__String_Unicode(space, w_left, w_right):
# this function is needed to make 'abc'.__add__(u'def') return
# u'abcdef' instead of NotImplemented. This is what occurs on
# top of CPython.
from pypy.objspace.std.unicodetype import unicode_from_string
# XXX fragile implementation detail: for "string + unicode subclass",
# if the unicode subclass overrides __radd__(), then it will be
# called (see test_str_unicode_concat_overrides). This occurs as a
# result of the following call to space.add() in which the first
# argument is a unicode and the second argument a subclass of unicode
# (and thus the usual logic about calling __radd__() first applies).
return space.add(unicode_from_string(space, w_left) , w_right)
示例4: str_rindex__String_Unicode_ANY_ANY
def str_rindex__String_Unicode_ANY_ANY(space, w_self, w_substr, w_start, w_end):
from pypy.objspace.std.unicodetype import unicode_from_string
return space.call_method(unicode_from_string(space, w_self),
'rindex', w_substr, w_start, w_end)
示例5: str_rstrip__String_Unicode
def str_rstrip__String_Unicode(space, w_self, w_chars):
from pypy.objspace.std.unicodetype import unicode_from_string
return space.call_method(unicode_from_string(space, w_self),
'rstrip', w_chars)
示例6: delegate_String2Unicode
def delegate_String2Unicode(space, w_str):
from pypy.objspace.std.unicodetype import unicode_from_string
w_uni = unicode_from_string(space, w_str)
assert isinstance(w_uni, W_UnicodeObject) # help the annotator!
return w_uni
示例7: unicode_lstrip__Unicode_String
def unicode_lstrip__Unicode_String(space, w_self, w_chars):
from pypy.objspace.std.unicodetype import unicode_from_string
return space.call_method(w_self, 'lstrip',
unicode_from_string(space, w_chars))
示例8: contains__String_Unicode
def contains__String_Unicode(space, w_container, w_item):
from pypy.objspace.std.unicodetype import unicode_from_string
return space.contains(unicode_from_string(space, w_container), w_item )
示例9: str_rsplit__String_Unicode_ANY
def str_rsplit__String_Unicode_ANY(space, w_self, w_delim, w_maxsplit):
from pypy.objspace.std.unicodetype import unicode_from_string
return space.call_method(unicode_from_string(space, w_self),
'rsplit', w_delim, w_maxsplit)
示例10: str_replace__String_Unicode_Unicode_ANY
def str_replace__String_Unicode_Unicode_ANY(space, w_self, w_old, w_new, w_maxsplit):
from pypy.objspace.std.unicodetype import unicode_from_string
return space.call_method(unicode_from_string(space, w_self),
'replace', w_old, w_new, w_maxsplit)