當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。