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


Python unicodedata.mirrored函数代码示例

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


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

示例1: print_Unicode_info

def print_Unicode_info(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)
开发者ID:GitBruno,项目名称:glyphIgo,代码行数:26,代码来源:glyphIgo.py

示例2: test_ucd_510

 def test_ucd_510(self):
     import unicodedata
     # In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
     self.assert_(unicodedata.mirrored(u"\u0f3a"))
     self.assert_(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.assert_(u"a".upper()==u'A')
     self.assert_(u"\u1d79".upper()==u'\ua77d')
开发者ID:Partoo,项目名称:SMSView,代码行数:9,代码来源:test_unicodedata.py

示例3: overview

def overview(tree_item):
    """ Returns an overview of the character
    """
    char = tree_item.obj
    return TEMPLATE.format(unicodedata.name(char, '<NO NAME AVAILABLE>'), 
                           char, 
                           unicodedata.decimal(char, ''),
                           unicodedata.digit(char, ''),
                           unicodedata.numeric(char, ''),
                           unicodedata.category(char),
                           unicodedata.bidirectional(char),
                           unicodedata.combining(char),
                           unicodedata.east_asian_width(char),
                           unicodedata.mirrored(char),
                           unicodedata.decomposition(char))                          
开发者ID:lebedov,项目名称:objbrowser,代码行数:15,代码来源:unicode_browser.py

示例4: apply_mirroring

def apply_mirroring(storage, debug):
    """Applies L4: mirroring

    See: http://unicode.org/reports/tr9/#L4

    """
    # L4. A character is depicted by a mirrored glyph if and only if (a) the
    # resolved directionality of that character is R, and (b) the
    # Bidi_Mirrored property value of that character is true.
    for _ch in storage['chars']:
        unichar = _ch['ch']
        if mirrored(unichar) and \
                _embedding_direction(_ch['level']) == 'R':
            _ch['ch'] = MIRRORED.get(unichar, unichar)

    if debug:
        debug_storage(storage)
开发者ID:pylover,项目名称:python-bidi,代码行数:17,代码来源:algorithm.py

示例5: test_compare_functions

    def test_compare_functions(self):
        def getX(fun, code):
            try:
                return getattr(unicodedb_5_2_0, fun)(code)
            except KeyError:
                return -1

        for code in range(0x10000):
            char = unichr(code)
            assert unicodedata.digit(char, -1) == getX('digit', code)
            assert unicodedata.numeric(char, -1) == getX('numeric', code)
            assert unicodedata.decimal(char, -1) == getX('decimal', code)
            assert unicodedata.category(char) == unicodedb_5_2_0.category(code)
            assert unicodedata.bidirectional(char) == unicodedb_5_2_0.bidirectional(code)
            assert unicodedata.decomposition(char) == unicodedb_5_2_0.decomposition(code)
            assert unicodedata.mirrored(char) == unicodedb_5_2_0.mirrored(code)
            assert unicodedata.combining(char) == unicodedb_5_2_0.combining(code)
开发者ID:mozillazg,项目名称:pypy,代码行数:17,代码来源:test_unicodedata.py

示例6: main

def main():
  try:
    v = bytes(int(x, 16) for x in sys.argv[1:])
    c = v.decode('utf8')
    print('gryph:            %s' % c)
    print('codepoint:        U+%x' % ord(c))
    print('name:             %s' % unicodedata.name(c, 'Unknown'))
    print('decimal:          %s' % unicodedata.decimal(c, 'Unknown'))
    print('digit:            %s' % unicodedata.digit(c, 'Unknown'))
    print('numeric:          %s' % unicodedata.numeric(c, 'Unknown'))
    print('category:         %s' % unicodedata.category(c))
    print('bidirectional:    %s' % unicodedata.bidirectional(c))
    print('combining:        %s' % unicodedata.combining(c))
    print('east_asian_width: %s' % unicodedata.east_asian_width(c))
    print('mirrored:         %s' % unicodedata.mirrored(c))
    print('decomposition:    %s' % unicodedata.decomposition(c))
  except Exception as ex:
    print('ERROR: %s' % ex)
开发者ID:odashi,项目名称:nlptools,代码行数:18,代码来源:show_utf8_char.py

示例7: test_compare_functions

    def test_compare_functions(self):
        import unicodedata # CPython implementation

        def getX(fun, code):
            if fun == 'numeric' and code in self.diff_numeric:
                return -1
            try:
                return getattr(unicodedb_4_1_0, fun)(code)
            except KeyError:
                return -1
        
        for code in range(0x10000):
            char = unichr(code)
            assert unicodedata.digit(char, -1) == getX('digit', code)
            assert unicodedata.numeric(char, -1) == getX('numeric', code)
            assert unicodedata.decimal(char, -1) == getX('decimal', code)
            assert unicodedata.category(char) == unicodedb_4_1_0.category(code)
            assert unicodedata.bidirectional(char) == unicodedb_4_1_0.bidirectional(code)
            assert unicodedata.decomposition(char) == unicodedb_4_1_0.decomposition(code)
            assert unicodedata.mirrored(char) == unicodedb_4_1_0.mirrored(code)
            assert unicodedata.combining(char) == unicodedb_4_1_0.combining(code)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:21,代码来源:test_unicodedata.py

示例8: test_ipy2_gh357

    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,代码行数:22,代码来源:test_regressions.py

示例9: printUnicodeInfo

 def printUnicodeInfo( text, description ):
     print( "{}:".format( description ) )
     for j,char in enumerate(text):
         print( "{:2} {:04x} {} '{}'   (cat={} bid={} comb={} mirr={})" \
             .format(j, ord(char), unicodedata.name(char), char, unicodedata.category(char), unicodedata.bidirectional(char), unicodedata.combining(char), unicodedata.mirrored(char) ) )
开发者ID:beniza,项目名称:BibleOrgSys,代码行数:5,代码来源:Hebrew.py

示例10: test_mirrored

    def test_mirrored(self):
        import unicodedata

        # For no reason, unicodedata.mirrored() returns an int, not a bool
        assert repr(unicodedata.mirrored(u" ")) == "0"
开发者ID:cimarieta,项目名称:usp,代码行数:5,代码来源:test_unicodedata.py

示例11: charinfo

    async def charinfo(self, *, data: str):
        """Shows information about one or several characters.

        'data' can either be a character, a unicode escape sequence, a unicode character name or a string.
        If 'data' is a string only a summary of each character's info will be displayed.
        """
        data = data.lower()

        if data.startswith('\\u'):
            # Let's interpret the unicode escape sequence
            hex_values = data.split('\\u')[1:]
            try:
                code_points = [int(val, 16) for val in hex_values]
            except ValueError:
                await self.bot.say('Invalid unicode escape sequence.')
                return
            else:
                data = ''.join(chr(cp) for cp in code_points)
        elif len(data) > 1:
            # Maybe we've been given the character's name ?
            try:
                data = unicodedata.lookup(data)
            except KeyError:
                pass

        # Normalise the input
        data = unicodedata.normalize('NFC', data)
        url_fmt = '<http://unicode-table.com/en/{:X}>'

        if len(data) == 1:
            # Detailed info on the character
            entries = [
                ('Character', data),
                ('Name', unicodedata.name(data, 'None')),
                ('Code point', '{:04x}'.format(ord(data)))
            ]
            decomposition = unicodedata.decomposition(data)
            if decomposition != '':
                entries.append(('Decomposition', decomposition))

            combining = unicodedata.combining(data)
            if combining:
                entries.append(('Combining class', combining))

            entries.append(('Category', unicodedata.category(data)))
            bidirectional = unicodedata.bidirectional(data)
            entries.append(('Bidirectional', bidirectional if bidirectional != '' else 'None'))
            entries.append(('Mirrored', 'True' if unicodedata.mirrored(data) == 1 else 'False'))
            entries.append(('East asian width', unicodedata.east_asian_width(data)))
            entries.append(('Url', url_fmt.format(ord(data))))

            # Create the message's content and send it
            content = utils.indented_entry_to_str(entries)
            await self.bot.say_block(content)
        else:
            # Minimal info for each character
            entries = []
            for char in data:
                entries.append('{} | `\\u{:04x}` | {} | {}'.format(char,
                                                                   ord(char),
                                                                   unicodedata.name(char, 'None'),
                                                                   url_fmt.format(ord(char))))
            content = '\n'.join(entries)
            await self.bot.say(content)
开发者ID:sethlansky,项目名称:Atwater-Twitter-Alerts,代码行数:64,代码来源:info.py

示例12: printUnicodeData

    def printUnicodeData( self, text=None ):
        """
        """
        #print( "unicodedata", unicodedata.unidata_version )

        if text is None: text = self.currentText

        #def printUnicodeInfo( text, description ):
            #print( "{}:".format( description ) )
        for j,char in enumerate(text):
            print( "{:2} {:04x} {} {!r}   (cat={} bid={} comb={} mirr={})" \
                .format(j, ord(char), unicodedata.name(char), char, unicodedata.category(char), unicodedata.bidirectional(char), unicodedata.combining(char), unicodedata.mirrored(char) ) )
开发者ID:openscriptures,项目名称:BibleOrgSys,代码行数:12,代码来源:Hebrew.py

示例13:

assert unicodedata.numeric(u'A',None) is None
assert unicodedata.numeric(u'9') == 9
assert unicodedata.numeric(u'\u215b') == 0.125
assert unicodedata.numeric(u'\u2468') == 9.0

assert unicodedata.decimal(u'A',None) is None
assert unicodedata.decimal(u'9') == 9
assert unicodedata.decimal(u'\u215b',None) is None
assert unicodedata.decimal(u'\u2468',None) is None

assert unicodedata.category(u'\uFFFE') == 'Cn'
assert unicodedata.category(u'a') == 'Ll'
assert unicodedata.category(u'A') == 'Lu'

assert unicodedata.bidirectional(u'\uFFFE') == ''
assert unicodedata.bidirectional(u' ') == 'WS'
assert unicodedata.bidirectional(u'A') == 'L'

assert unicodedata.decomposition(u'\uFFFE') == ''
assert unicodedata.decomposition(u'\u00bc') == '<fraction> 0031 2044 0034'

assert unicodedata.mirrored(u'\uFFFE') == 0
assert unicodedata.mirrored(u'a') == 0
assert unicodedata.mirrored(u'\u2201') == 1

assert unicodedata.combining(u'\uFFFE') == 0
assert unicodedata.combining(u'a') == 0
assert unicodedata.combining(u'\u20e1') == 230

print 'done.'
开发者ID:asottile,项目名称:ancient-pythons,代码行数:30,代码来源:161_test_unicodedata.py

示例14: verify

verify(unicodedata.numeric(u"A", None) is None)
verify(unicodedata.numeric(u"9") == 9)
verify(unicodedata.numeric(u"\u215b") == 0.125)
verify(unicodedata.numeric(u"\u2468") == 9.0)

verify(unicodedata.decimal(u"A", None) is None)
verify(unicodedata.decimal(u"9") == 9)
verify(unicodedata.decimal(u"\u215b", None) is None)
verify(unicodedata.decimal(u"\u2468", None) is None)

verify(unicodedata.category(u"\uFFFE") == "Cn")
verify(unicodedata.category(u"a") == "Ll")
verify(unicodedata.category(u"A") == "Lu")

verify(unicodedata.bidirectional(u"\uFFFE") == "")
verify(unicodedata.bidirectional(u" ") == "WS")
verify(unicodedata.bidirectional(u"A") == "L")

verify(unicodedata.decomposition(u"\uFFFE") == "")
verify(unicodedata.decomposition(u"\u00bc") == "<fraction> 0031 2044 0034")

verify(unicodedata.mirrored(u"\uFFFE") == 0)
verify(unicodedata.mirrored(u"a") == 0)
verify(unicodedata.mirrored(u"\u2201") == 1)

verify(unicodedata.combining(u"\uFFFE") == 0)
verify(unicodedata.combining(u"a") == 0)
verify(unicodedata.combining(u"\u20e1") == 230)

print "ok"
开发者ID:zhoupan,项目名称:OpenModelSphereMirror,代码行数:30,代码来源:test_unicodedata.py

示例15: verify

verify(unicodedata.numeric(u'A',None) is None)
verify(unicodedata.numeric(u'9') == 9)
verify(unicodedata.numeric(u'\u215b') == 0.125)
verify(unicodedata.numeric(u'\u2468') == 9.0)

verify(unicodedata.decimal(u'A',None) is None)
verify(unicodedata.decimal(u'9') == 9)
verify(unicodedata.decimal(u'\u215b',None) is None)
verify(unicodedata.decimal(u'\u2468',None) is None)

verify(unicodedata.category(u'\uFFFE') == 'Cn')
verify(unicodedata.category(u'a') == 'Ll')
verify(unicodedata.category(u'A') == 'Lu')

verify(unicodedata.bidirectional(u'\uFFFE') == '')
verify(unicodedata.bidirectional(u' ') == 'WS')
verify(unicodedata.bidirectional(u'A') == 'L')

verify(unicodedata.decomposition(u'\uFFFE') == '')
verify(unicodedata.decomposition(u'\u00bc') == '<fraction> 0031 2044 0034')

verify(unicodedata.mirrored(u'\uFFFE') == 0)
verify(unicodedata.mirrored(u'a') == 0)
verify(unicodedata.mirrored(u'\u2201') == 1)

verify(unicodedata.combining(u'\uFFFE') == 0)
verify(unicodedata.combining(u'a') == 0)
verify(unicodedata.combining(u'\u20e1') == 230)

print 'ok'
开发者ID:BackupTheBerlios,项目名称:etpe-svn,代码行数:30,代码来源:test_unicodedata.py


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