summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMårten Nordheim <[email protected]>2025-06-17 17:55:49 +0200
committerMårten Nordheim <[email protected]>2025-07-03 13:49:55 +0200
commit8bc8951f7fb9eb344acacdbbacadd1f832453466 (patch)
tree7c47f25a3e8924202d96677885fe5427235790b7
parent1685ee36ebb7c906ed037731fc4d06fbfca6d6d6 (diff)
cldr2qlocalexml/localetools: Open files as UTF-8HEADdev
To avoid errors like: 'charmap' codec can't encode character '\u02bc' in position <x> Pick-to: 6.10 6.9 6.8 Task-number: QTBUG-137782 Change-Id: I100485c14121e5ffad7b0106e617b7f0afd7822e Reviewed-by: Edward Welbourne <[email protected]>
-rwxr-xr-xutil/locale_database/cldr2qlocalexml.py2
-rw-r--r--util/locale_database/localetools.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/util/locale_database/cldr2qlocalexml.py b/util/locale_database/cldr2qlocalexml.py
index d4ba6960517..0aa04b64b05 100755
--- a/util/locale_database/cldr2qlocalexml.py
+++ b/util/locale_database/cldr2qlocalexml.py
@@ -83,7 +83,7 @@ def main(argv: list[str], out: TextIO, err: TextIO) -> int:
parser.error(f'Please use a .xml extension on your output file name, not {xml}')
else:
try:
- emit = open(xml, 'w')
+ emit = open(xml, 'w', encoding="utf-8")
except IOError as e:
parser.error(f'Failed to open "{xml}" to write output to it')
diff --git a/util/locale_database/localetools.py b/util/locale_database/localetools.py
index 10937df5485..818880d6efa 100644
--- a/util/locale_database/localetools.py
+++ b/util/locale_database/localetools.py
@@ -110,7 +110,7 @@ def AtomicRenameTemporaryFile(originalLocation: Path, *, prefix: str, dir: Path)
On success closes the temporary file and moves its content to the original
location. On error, removes temporary file, without disturbing the original.
"""
- tempFile = NamedTemporaryFile('w', prefix=prefix, dir=dir, delete=False)
+ tempFile = NamedTemporaryFile('w', prefix=prefix, dir=dir, delete=False, encoding='utf-8')
try:
yield tempFile
tempFile.close()
@@ -174,7 +174,7 @@ class Transcriber:
self.writer = resources.enter_context(
AtomicRenameTemporaryFile(self.path, prefix=self.path.name, dir=self.tempDir))
# Open the old file
- self.reader = resources.enter_context(open(self.path))
+ self.reader = resources.enter_context(open(self.path, encoding='utf-8'))
self.onEnter()