mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
@@ -236,11 +236,17 @@ def filepath_to_uri(path):
|
||||
# some flexibility for hardcoding separators.
|
||||
return quote(force_bytes(path.replace("\\", "/")), safe=b"/~!*()'")
|
||||
|
||||
# The encoding of the default system locale but falls back to the
|
||||
# given fallback encoding if the encoding is unsupported by python or could
|
||||
# not be determined. See tickets #10335 and #5846
|
||||
try:
|
||||
DEFAULT_LOCALE_ENCODING = locale.getdefaultlocale()[1] or 'ascii'
|
||||
codecs.lookup(DEFAULT_LOCALE_ENCODING)
|
||||
except:
|
||||
DEFAULT_LOCALE_ENCODING = 'ascii'
|
||||
def get_system_encoding():
|
||||
"""
|
||||
The encoding of the default system locale but falls back to the given
|
||||
fallback encoding if the encoding is unsupported by python or could
|
||||
not be determined. See tickets #10335 and #5846
|
||||
"""
|
||||
try:
|
||||
encoding = locale.getdefaultlocale()[1] or 'ascii'
|
||||
codecs.lookup(encoding)
|
||||
except Exception:
|
||||
encoding = 'ascii'
|
||||
return encoding
|
||||
|
||||
DEFAULT_LOCALE_ENCODING = get_system_encoding()
|
||||
|
||||
Reference in New Issue
Block a user