本文整理汇总了Python中pandac.PandaModules.TextEncoder.encodeWtext方法的典型用法代码示例。如果您正苦于以下问题:Python TextEncoder.encodeWtext方法的具体用法?Python TextEncoder.encodeWtext怎么用?Python TextEncoder.encodeWtext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.TextEncoder
的用法示例。
在下文中一共展示了TextEncoder.encodeWtext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkJapanese
# 需要导入模块: from pandac.PandaModules import TextEncoder [as 别名]
# 或者: from pandac.PandaModules.TextEncoder import encodeWtext [as 别名]
def checkJapanese(name):
asciiSpace = range(32, 33)
asciiDigits = range(48, 64)
hiragana = range(12353, 12448)
katakana = range(12449, 12544)
halfwidthKatakana = range(65381, 65440)
halfwidthCharacter = set(asciiSpace + halfwidthKatakana)
allowedUtf8 = set(asciiSpace + hiragana + katakana + halfwidthKatakana)
te = TextEncoder()
dc = 0.0
for char in (ord(char) for char in te.decodeText(name)):
if char not in allowedUtf8:
if char in asciiDigits:
notify.info('name contains not allowed ascii digits')
return OTPLocalizer.NCNoDigits
else:
notify.info('name contains not allowed utf8 char: 0x%04x' % char)
return OTPLocalizer.NCBadCharacter % te.encodeWtext(unichr(char))
elif char in halfwidthCharacter:
dc += 0.5
else:
dc += 1
if dc < 2:
notify.info('name is too short: %0.1f' % dc)
return OTPLocalizer.NCTooShort
elif dc > 8:
notify.info('name has been occupied more than eight display cells: %0.1f' % dc)
return OTPLocalizer.NCGeneric