Skip to content

Instantly share code, notes, and snippets.

@cou929
Created November 24, 2012 03:51
Show Gist options
  • Save cou929/4138273 to your computer and use it in GitHub Desktop.
Save cou929/4138273 to your computer and use it in GitHub Desktop.
locale で 'ValueError: unknown locale: UTF-8' というエラーがでた
def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
# 略
import os
lookup = os.environ.get
for variable in envvars:
localename = lookup(variable,None)
if localename:
if variable == 'LANGUAGE':
localename = localename.split(':')[0]
break
else:
localename = 'C'
return _parse_localename(localename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment