mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Workaround for broken linux installs with encoding set to ANSI_X3.4-1968
Got a second bug report from a user running such a system today. So workaround it.
This commit is contained in:
parent
e49227ee40
commit
9b18bd674e
@ -30,9 +30,10 @@ del err
|
|||||||
icu_unicode_version = getattr(_icu, 'unicode_version', None)
|
icu_unicode_version = getattr(_icu, 'unicode_version', None)
|
||||||
_nmodes = {m:getattr(_icu, 'UNORM_'+m, None) for m in ('NFC', 'NFD', 'NFKC', 'NFKD', 'NONE', 'DEFAULT', 'FCD')}
|
_nmodes = {m:getattr(_icu, 'UNORM_'+m, None) for m in ('NFC', 'NFD', 'NFKC', 'NFKD', 'NONE', 'DEFAULT', 'FCD')}
|
||||||
|
|
||||||
|
ascii_encodings = {b'ansi_x3.4-1968', b'ascii'}
|
||||||
try:
|
try:
|
||||||
senc = sys.getdefaultencoding()
|
senc = sys.getdefaultencoding()
|
||||||
if not senc or senc.lower() == b'ascii':
|
if not senc or senc.lower() in ascii_encodings:
|
||||||
_icu.set_default_encoding(b'utf-8')
|
_icu.set_default_encoding(b'utf-8')
|
||||||
del senc
|
del senc
|
||||||
except:
|
except:
|
||||||
@ -41,12 +42,13 @@ except:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
fenc = sys.getfilesystemencoding()
|
fenc = sys.getfilesystemencoding()
|
||||||
if not fenc or fenc.lower() == b'ascii':
|
if not fenc or fenc.lower() in ascii_encodings:
|
||||||
_icu.set_filesystem_encoding(b'utf-8')
|
_icu.set_filesystem_encoding(b'utf-8')
|
||||||
del fenc
|
del fenc
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
del ascii_encodings
|
||||||
|
|
||||||
def collator():
|
def collator():
|
||||||
global _collator, _locale
|
global _collator, _locale
|
||||||
|
Loading…
x
Reference in New Issue
Block a user