当前位置: 首页>>代码示例>>Python>>正文


Python W_String.fromunicode方法代码示例

本文整理汇总了Python中pycket.values_string.W_String.fromunicode方法的典型用法代码示例。如果您正苦于以下问题:Python W_String.fromunicode方法的具体用法?Python W_String.fromunicode怎么用?Python W_String.fromunicode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycket.values_string.W_String的用法示例。


在下文中一共展示了W_String.fromunicode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: char_utf_8_length

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def char_utf_8_length(char):
    # same as (bytes-length (string->bytes/utf-8 (string char)))
    builder = UnicodeBuilder()
    builder.append(char.value)
    w_str = W_String.fromunicode(builder.build())
    w_bytes = values.W_Bytes.from_charlist(w_str.as_charlist_utf8())
    return values.W_Fixnum(w_bytes.length())
开发者ID:pycket,项目名称:pycket,代码行数:9,代码来源:string.py

示例2: bytes_to_string_latin

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def bytes_to_string_latin(w_bytes, err, start, end):
    str = w_bytes.as_str().decode("latin-1")

    # From Racket Docs: The err-char argument is ignored, but present
    # for consistency with the other operations.

    return get_substring(W_String.fromunicode(str), start, end)
开发者ID:pycket,项目名称:pycket,代码行数:9,代码来源:string.py

示例3: string

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def string(args):
    if len(args) == 0:
        return W_String.fromascii("")
    assert len(args) > 0
    builder = UnicodeBuilder()
    # XXX could do one less copy in the ascii case
    for char in args:
        if not isinstance(char, values.W_Character):
            raise SchemeException("string: expected a character")
        builder.append(char.value)
    return W_String.fromunicode(builder.build())
开发者ID:8l,项目名称:pycket,代码行数:13,代码来源:string.py

示例4: make_string

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def make_string(k, char):
    if char is None:
        char = u'\0'
    else:
        char = char.value
    c = ord(char)
    if k.value < 0:
        raise SchemeException("make-string: around negative")
    if c < 128:
        char = chr(c)
        return W_String.fromascii(char * k.value)
    else:
        char = unichr(c)
        return W_String.fromunicode(char * k.value)
开发者ID:8l,项目名称:pycket,代码行数:16,代码来源:string.py

示例5: string_append

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def string_append(args):
    if not args:
        return W_String.fromascii("")
    builder = StringBuilder()
    unibuilder = None
    for a in args:
        if not isinstance(a, W_String):
            raise SchemeException("string-append: expected a string")
        if unibuilder is None:
            try:
                builder.append(a.as_str_ascii())
                continue
            except ValueError:
                unibuilder = UnicodeBuilder()
                unibuilder.append(unicode(builder.build()))
        unibuilder.append(a.as_unicode())
    if unibuilder is None:
        return W_String.fromascii(builder.build())
    else:
        return W_String.fromunicode(unibuilder.build())
开发者ID:8l,项目名称:pycket,代码行数:22,代码来源:string.py

示例6: symbol_to_string

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def symbol_to_string(v):
    if v.asciivalue is not None:
        return W_String.fromascii(v.asciivalue)
    return W_String.fromunicode(v.unicodevalue)
开发者ID:8l,项目名称:pycket,代码行数:6,代码来源:string.py

示例7: symbol_to_string_impl

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def symbol_to_string_impl(v):
    asciivalue = v.asciivalue()
    if asciivalue is not None:
        return W_String.fromascii(asciivalue)
    return W_String.fromunicode(v.unicodevalue())
开发者ID:pycket,项目名称:pycket,代码行数:7,代码来源:string.py

示例8: bytes_to_string_latin

# 需要导入模块: from pycket.values_string import W_String [as 别名]
# 或者: from pycket.values_string.W_String import fromunicode [as 别名]
def bytes_to_string_latin(w_bytes, err, start, end):
    # XXX Not a valid implementation
    str = w_bytes.as_str().decode("latin-1")
    return W_String.fromunicode(str)
开发者ID:magnusmorton,项目名称:pycket,代码行数:6,代码来源:string.py


注:本文中的pycket.values_string.W_String.fromunicode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。