mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -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)
|
||||
_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:
|
||||
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')
|
||||
del senc
|
||||
except:
|
||||
@ -41,12 +42,13 @@ except:
|
||||
|
||||
try:
|
||||
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')
|
||||
del fenc
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
del ascii_encodings
|
||||
|
||||
def collator():
|
||||
global _collator, _locale
|
||||
|
Loading…
x
Reference in New Issue
Block a user