whatstyle.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:whatstyle 作者: mikr 项目源码 文件源码
def iterchars(text):
        # type: (str) -> Sequence[str]
        idx = 0
        chars = []
        while idx < len(text):
            c = text[idx]
            if ord(c) >= 0x100:
                highchar = True
                if ((0xD800 <= ord(c) <= 0xDBFF) and (idx < len(text) - 1) and
                    (0xDC00 <= ord(text[idx + 1]) <= 0xDFFF)):
                    c = text[idx:idx + 2]
                    # Skip the other half of the lead and trail surrogate
                    idx += 1
            else:
                highchar = False
            idx += 1
            # Add every character except only one half of a surrogate pair.
            if not (highchar and len(c) == 1 and 0xD800 <= ord(c) <= 0xDFFF):
                chars.append(c)
        return chars
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号