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