summaryrefslogtreecommitdiffstats
path: root/util/locale_database
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-01-13 15:01:55 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-01-29 15:23:16 +0100
commit0ef79d94f6dcf276ca55b084d27f980b1f260473 (patch)
tree87fedf0bcda642df74da567294ccc99470eafb0a /util/locale_database
parent4cbadf699838406d14366ce61deec03cf45113f7 (diff)
Ensure we use UTF-8 for the emitted QLocaleXML data file
Python helpfully uses a sensible locale when stdout is a tty but uses the system (not the filesystem) default encoding, which may be ascii and unable to encode some of the data we need to save. So brute force kludge it to ensure sys.stdout.encoding is UTF-8 when writing the output we'll read as UTF-8 anyway. Task-number: QTBUG-79902 Change-Id: I218dc0ec4c71a6b1b7181db55b018266d803bc58 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'util/locale_database')
-rwxr-xr-xutil/locale_database/cldr2qlocalexml.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py
index 072ea9e4ed..de9fe57115 100755
--- a/util/locale_database/cldr2qlocalexml.py
+++ b/util/locale_database/cldr2qlocalexml.py
@@ -2,7 +2,7 @@
# coding=utf8
#############################################################################
##
-## Copyright (C) 2018 The Qt Company Ltd.
+## Copyright (C) 2020 The Qt Company Ltd.
## Contact: https://www.qt.io/licensing/
##
## This file is part of the test suite of the Qt Toolkit.
@@ -582,6 +582,10 @@ for line in ldml:
if 'version cldrVersion CDATA #FIXED' in line:
cldr_version = line.split('"')[1]
+if sys.stdout.encoding != 'UTF-8' or (sys.stdout.encoding is None and sys.getdefaultencoding() != 'UTF-8'):
+ reload(sys) # Weirdly, this gets a richer sys module than the plain import got us !
+ sys.setdefaultencoding('UTF-8')
+
print "<localeDatabase>"
print " <version>" + cldr_version + "</version>"
print " <languageList>"