"""Locale utility routines."""
+__all__ = ["localelist", "encoding", "getpair"]
+
import sys
try:
except ImportError:
codecs = None
-__all__ = ["localelist"]
-
def localelist(*locales):
"""Normalize and return a list of locales, with appended defaults.
if fromlocale is not None:
return fromlocale
try:
- locale.setlocale(locale.LC_COLLATE, '')[1]
+ locale.setlocale(locale.LC_COLLATE, '')
except locale.Error:
pass
else:
return locale.getpreferredencoding() or sys.getdefaultencoding()
def getpair(locale_, encoding_):
+ """If encoding_ is unspecified, get the locale encoding."""
if "." in locale_:
if encoding_ is None:
locale_, encoding_ = locale_.rsplit(".", 1)