我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用_locale.nl_langinfo()。
def getpreferredencoding(do_setlocale=True): assert not do_setlocale result = _locale.nl_langinfo(_locale.CODESET) if not result and sys.platform == 'darwin': # nl_langinfo can return an empty string # when the setting has an invalid value. # Default to UTF-8 in that case because # UTF-8 is the default charset on OSX and # returning nothing will crash the # interpreter. result = 'UTF-8' return result