示例#1
0
文件: reader.py 项目: ArneBab/pypyjs
    uc_map['\t'] = '    ' # display TABs as 4 characters
    uc_map['\177'] = u'^?'
    for i in range(256):
        c = unichr(i)
        if not uc_map.has_key(c):
            uc_map[c] = u'\\%03o'%i
    return uc_map

# disp_str proved to be a bottleneck for large inputs, so it's been
# rewritten in C; it's not required though.
try:
    raise ImportError # currently it's borked by the unicode support

    from _pyrepl_utils import disp_str, init_unctrl_map

    init_unctrl_map(_make_unctrl_map())

    del init_unctrl_map
except ImportError:
    def _my_unctrl(c, u=_make_unctrl_map()):
        if c in u:
            return u[c]
        else:
            if unicodedata_.category(c).startswith('C'):
                return '\u%04x'%(ord(c),)
            else:
                return c

    def disp_str(buffer, join=''.join, uc=_my_unctrl):
        """ disp_str(buffer:string) -> (string, [int])
示例#2
0
文件: reader.py 项目: truewangk/pypy
    uc_map['\177'] = u'^?'
    for i in range(256):
        c = unichr(i)
        if not uc_map.has_key(c):
            uc_map[c] = u'\\%03o' % i
    return uc_map


# disp_str proved to be a bottleneck for large inputs, so it's been
# rewritten in C; it's not required though.
try:
    raise ImportError  # currently it's borked by the unicode support

    from _pyrepl_utils import disp_str, init_unctrl_map

    init_unctrl_map(_make_unctrl_map())

    del init_unctrl_map
except ImportError:

    def _my_unctrl(c, u=_make_unctrl_map()):
        if c in u:
            return u[c]
        else:
            if unicodedata_.category(c).startswith('C'):
                return '\u%04x' % (ord(c), )
            else:
                return c

    def disp_str(buffer, join=''.join, uc=_my_unctrl):
        """ disp_str(buffer:string) -> (string, [int])