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


Python locale.LC_CTYPE属性代码示例

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


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

示例1: test_getsetlocale_issue1813

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_getsetlocale_issue1813(self):
        # Issue #1813: setting and getting the locale under a Turkish locale
        oldlocale = locale.getlocale()
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
        for loc in ('tr_TR', 'tr_TR.UTF-8', 'tr_TR.ISO8859-9'):
            try:
                locale.setlocale(locale.LC_CTYPE, loc)
                break
            except locale.Error:
                continue
        else:
            # Unsupported locale on this system
            self.skipTest('test needs Turkish locale')
        loc = locale.getlocale()
        try:
            locale.setlocale(locale.LC_CTYPE, loc)
        except Exception as e:
            self.fail("Failed to set locale %r (default locale is %r): %r" %
                      (loc, oldlocale, e))
        self.assertEqual(loc, locale.getlocale()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_locale.py

示例2: test_locale_caching

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_locale_caching(self):
        # Issue #22410
        oldlocale = locale.setlocale(locale.LC_CTYPE)
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
        for loc in 'en_US.iso88591', 'en_US.utf8':
            try:
                locale.setlocale(locale.LC_CTYPE, loc)
            except locale.Error:
                # Unsupported locale on this system
                self.skipTest('test needs %s locale' % loc)

        re.purge()
        self.check_en_US_iso88591()
        self.check_en_US_utf8()
        re.purge()
        self.check_en_US_utf8()
        self.check_en_US_iso88591() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_re.py

示例3: test_setlocale_category

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_setlocale_category(self):
        locale.setlocale(locale.LC_ALL)
        locale.setlocale(locale.LC_TIME)
        locale.setlocale(locale.LC_CTYPE)
        locale.setlocale(locale.LC_COLLATE)
        locale.setlocale(locale.LC_MONETARY)
        locale.setlocale(locale.LC_NUMERIC)

        # crasher from bug #7419
        self.assertRaises(locale.Error, locale.setlocale, 12345) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_locale.py

示例4: test_setlocale_unicode

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_setlocale_unicode(self):
        oldlocale = locale.getlocale()
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)

        user_locale = locale.setlocale(locale.LC_CTYPE, '')
        unicode_locale = user_locale.decode('utf-8')

        user_locale2 = locale.setlocale(locale.LC_CTYPE, unicode_locale)
        self.assertEqual(user_locale, user_locale2) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_locale.py

示例5: test_lookup_issue1813

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_lookup_issue1813(self):
        # Issue #1813: under Turkish locales, lookup of some codecs failed
        # because 'I' is lowercased as a dotless "i"
        oldlocale = locale.getlocale(locale.LC_CTYPE)
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
        try:
            locale.setlocale(locale.LC_CTYPE, 'tr_TR')
        except locale.Error:
            # Unsupported locale on this system
            self.skipTest('test needs Turkish locale')
        c = codecs.lookup('ASCII')
        self.assertEqual(c.name, 'ascii') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_codecs.py

示例6: check_en_US_utf8

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def check_en_US_utf8(self):
        locale.setlocale(locale.LC_CTYPE, 'en_US.utf8')
        self.assertTrue(re.match(b'\xc5\xe5', b'\xc5\xe5', re.L|re.I))
        self.assertIsNone(re.match(b'\xc5', b'\xe5', re.L|re.I))
        self.assertIsNone(re.match(b'\xe5', b'\xc5', re.L|re.I))
        self.assertTrue(re.match(b'(?Li)\xc5\xe5', b'\xc5\xe5'))
        self.assertIsNone(re.match(b'(?Li)\xc5', b'\xe5'))
        self.assertIsNone(re.match(b'(?Li)\xe5', b'\xc5')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_re.py

示例7: test_getsetlocale_issue1813

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_getsetlocale_issue1813(self):
        # Issue #1813: setting and getting the locale under a Turkish locale
        oldlocale = locale.getlocale()
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
        try:
            locale.setlocale(locale.LC_CTYPE, 'tr_TR')
        except locale.Error:
            # Unsupported locale on this system
            self.skipTest('test needs Turkish locale')
        loc = locale.getlocale()
        locale.setlocale(locale.LC_CTYPE, loc)
        self.assertEqual(loc, locale.getlocale()) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:14,代码来源:test_locale.py

示例8: check_en_US_iso88591

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def check_en_US_iso88591(self):
        locale.setlocale(locale.LC_CTYPE, 'en_US.iso88591')
        self.assertTrue(re.match(b'\xc5\xe5', b'\xc5\xe5', re.L|re.I))
        self.assertTrue(re.match(b'\xc5', b'\xe5', re.L|re.I))
        self.assertTrue(re.match(b'\xe5', b'\xc5', re.L|re.I))
        self.assertTrue(re.match(b'(?Li)\xc5\xe5', b'\xc5\xe5'))
        self.assertTrue(re.match(b'(?Li)\xc5', b'\xe5'))
        self.assertTrue(re.match(b'(?Li)\xe5', b'\xc5')) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:10,代码来源:test_re.py

示例9: test_getsetlocale_issue1813

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_getsetlocale_issue1813(self):
        # Issue #1813: setting and getting the locale under a Turkish locale
        oldlocale = locale.setlocale(locale.LC_CTYPE)
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
        try:
            locale.setlocale(locale.LC_CTYPE, 'tr_TR')
        except locale.Error:
            # Unsupported locale on this system
            self.skipTest('test needs Turkish locale')
        loc = locale.getlocale(locale.LC_CTYPE)
        if verbose:
            print('testing with %a' % (loc,), end=' ', flush=True)
        locale.setlocale(locale.LC_CTYPE, loc)
        self.assertEqual(loc, locale.getlocale(locale.LC_CTYPE)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:test_locale.py

示例10: test_lookup_issue1813

# 需要导入模块: import locale [as 别名]
# 或者: from locale import LC_CTYPE [as 别名]
def test_lookup_issue1813(self):
        # Issue #1813: under Turkish locales, lookup of some codecs failed
        # because 'I' is lowercased as "ı" (dotless i)
        oldlocale = locale.setlocale(locale.LC_CTYPE)
        self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
        try:
            locale.setlocale(locale.LC_CTYPE, 'tr_TR')
        except locale.Error:
            # Unsupported locale on this system
            self.skipTest('test needs Turkish locale')
        c = codecs.lookup('ASCII')
        self.assertEqual(c.name, 'ascii') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:test_codecs.py


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