当前位置: 首页>>代码示例>>Python>>正文


Python unicodedata.mirrored方法代码示例

本文整理汇总了Python中unicodedata.mirrored方法的典型用法代码示例。如果您正苦于以下问题:Python unicodedata.mirrored方法的具体用法?Python unicodedata.mirrored怎么用?Python unicodedata.mirrored使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unicodedata的用法示例。


在下文中一共展示了unicodedata.mirrored方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_function_checksum

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_function_checksum(self):
        data = []
        h = hashlib.sha1()

        for i in range(0x10000):
            char = unichr(i)
            data = [
                # Properties
                str(self.db.digit(char, -1)),
                str(self.db.numeric(char, -1)),
                str(self.db.decimal(char, -1)),
                self.db.category(char),
                self.db.bidirectional(char),
                self.db.decomposition(char),
                str(self.db.mirrored(char)),
                str(self.db.combining(char)),
            ]
            h.update(''.join(data))
        result = h.hexdigest()
        self.assertEqual(result, self.expectedchecksum) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_unicodedata.py

示例2: test_ipy2_gh357

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_ipy2_gh357(self):
        """https://github.com/IronLanguages/ironpython2/issues/357"""

        import unicodedata

        if is_cli:
            self.assertEqual(unicodedata.name(u'\u4e2d'), '<CJK IDEOGRAPH, FIRST>..<CJK IDEOGRAPH, LAST>')
        else:
            self.assertEqual(unicodedata.name(u'\u4e2d'), 'CJK UNIFIED IDEOGRAPH-4E2D')

        self.assertRaises(ValueError, unicodedata.decimal, u'\u4e2d')
        self.assertEqual(unicodedata.decimal(u'\u4e2d', 0), 0)
        self.assertRaises(ValueError, unicodedata.digit, u'\u4e2d')
        self.assertEqual(unicodedata.digit(u'\u4e2d', 0), 0)
        self.assertRaises(ValueError, unicodedata.numeric, u'\u4e2d')
        self.assertEqual(unicodedata.numeric(u'\u4e2d', 0), 0)
        self.assertEqual(unicodedata.category(u'\u4e2d'), 'Lo')
        self.assertEqual(unicodedata.bidirectional(u'\u4e2d'), 'L')
        self.assertEqual(unicodedata.combining(u'\u4e2d'), 0)
        self.assertEqual(unicodedata.east_asian_width(u'\u4e2d'), 'W')
        self.assertEqual(unicodedata.mirrored(u'\u4e2d'), 0)
        self.assertEqual(unicodedata.decomposition(u'\u4e2d'), '') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_regressions.py

示例3: test_function_checksum

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_function_checksum(self):
        data = []
        h = hashlib.sha1()

        for i in range(0x10000):
            char = chr(i)
            data = [
                # Properties
                format(self.db.digit(char, -1), '.12g'),
                format(self.db.numeric(char, -1), '.12g'),
                format(self.db.decimal(char, -1), '.12g'),
                self.db.category(char),
                self.db.bidirectional(char),
                self.db.decomposition(char),
                str(self.db.mirrored(char)),
                str(self.db.combining(char)),
            ]
            h.update(''.join(data).encode("ascii"))
        result = h.hexdigest()
        self.assertEqual(result, self.expectedchecksum) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:test_unicodedata.py

示例4: test_mirrored

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_mirrored(self):
        self.assertEqual(self.db.mirrored(u'\uFFFE'), 0)
        self.assertEqual(self.db.mirrored(u'a'), 0)
        self.assertEqual(self.db.mirrored(u'\u2201'), 1)
        self.assertEqual(self.db.mirrored(u'\U00020000'), 0)

        self.assertRaises(TypeError, self.db.mirrored)
        self.assertRaises(TypeError, self.db.mirrored, u'xx') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_unicodedata.py

示例5: test_ucd_510

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_ucd_510(self):
        import unicodedata
        # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
        self.assertTrue(unicodedata.mirrored(u"\u0f3a"))
        self.assertTrue(not unicodedata.ucd_3_2_0.mirrored(u"\u0f3a"))
        # Also, we now have two ways of representing
        # the upper-case mapping: as delta, or as absolute value
        self.assertTrue(u"a".upper()==u'A')
        self.assertTrue(u"\u1d79".upper()==u'\ua77d')
        self.assertTrue(u".".upper()==u".") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_unicodedata.py

示例6: test_mirrored

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_mirrored(self):
        self.assertEqual(self.db.mirrored('\uFFFE'), 0)
        self.assertEqual(self.db.mirrored('a'), 0)
        self.assertEqual(self.db.mirrored('\u2201'), 1)
        self.assertEqual(self.db.mirrored('\U00020000'), 0)

        self.assertRaises(TypeError, self.db.mirrored)
        self.assertRaises(TypeError, self.db.mirrored, 'xx') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_unicodedata.py

示例7: test_ucd_510

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def test_ucd_510(self):
        import unicodedata
        # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
        self.assertTrue(unicodedata.mirrored("\u0f3a"))
        self.assertTrue(not unicodedata.ucd_3_2_0.mirrored("\u0f3a"))
        # Also, we now have two ways of representing
        # the upper-case mapping: as delta, or as absolute value
        self.assertTrue("a".upper()=='A')
        self.assertTrue("\u1d79".upper()=='\ua77d')
        self.assertTrue(".".upper()=='.') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_unicodedata.py

示例8: __print_Unicode_info

# 需要导入模块: import unicodedata [as 别名]
# 或者: from unicodedata import mirrored [as 别名]
def __print_Unicode_info(self, char, short):
        name = unicodedata.name(char, "UNKNOWN")
        decCodepoint = ord(char)
        hexCodepoint = hex(decCodepoint)
        lower = char.lower()
        upper = char.upper()
        category = unicodedata.category(char)
        bidirectional = unicodedata.bidirectional(char)
        mirrored = True if (unicodedata.mirrored(char) == 1) else False
        nfc = unicodedata.normalize("NFC", char)
        nfd = unicodedata.normalize("NFD", char)
        if (short):
            print char + "\t" + name + " (U+" + str(hexCodepoint).upper().replace("0X", "") + ")"
        else:
            print "Name          " + name 
            print "Character     " + char 
            print "Dec Codepoint " + str(decCodepoint)
            print "Hex Codepoint " + str(hexCodepoint)
            print "Lowercase     " + lower
            print "Uppercase     " + upper
            print "Category      " + category
            print "Bidirectional " + bidirectional
            print "Mirrored      " + str(mirrored)
            print "NFC           " + nfc
            print "NFD           " + nfd
            print "============="

    # helper: perform a lookup for the given query 
开发者ID:pettarin,项目名称:glyphIgo,代码行数:30,代码来源:glyphIgo.py


注:本文中的unicodedata.mirrored方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。