_function.py 文件源码

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

项目:DataProperty 作者: thombashi 项目源码 文件源码
def get_ascii_char_width(unicode_str, east_asian_ambiguous_width=1):
    import unicodedata

    width = 0
    for char in unicode_str:
        char_width = unicodedata.east_asian_width(char)
        if char_width in "WF":
            width += 2
        elif char_width == "A":
            _validate_eaaw(east_asian_ambiguous_width)
            width += east_asian_ambiguous_width
        else:
            width += 1

    return width
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号