NeteaseMusicLyricDownloader/modules/utils/length.py
2023-04-18 00:44:01 +08:00

13 lines
365 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""一些有关计算长度的工具"""
def len_abs(content):
"""针对中文将一个汉字识别为2个长度而不是1个"""
return len(content) + (len(content.encode("utf-8")) - len(content)) // 2
def get_more_length(content):
"""将相对于正常长度的超出值返回"""
return (len(content.encode("utf-8")) - len(content)) // 2