本文整理匯總了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())
示例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()
示例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)
示例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)
示例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')
示例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'))
示例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())
示例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'))
示例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))
示例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')