QLocaleXml: include a <?xml> preamble

Make our encoding explicit and enable more tools to understand what
they're looking at.

Change-Id: I29327364a5eaac51eeda9a4fb3b8e9b7527ca488
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Edward Welbourne 2024-06-03 17:10:41 +02:00
parent a9446b1c3b
commit 15019f8667

View File

@ -281,7 +281,7 @@ class Spacer (object):
indent = self.current
if line.startswith('</'):
indent = self.current = indent[:-len(self.__each)]
elif line.startswith('<') and not line.startswith('<!'):
elif line.startswith('<') and line[1:2] not in '!?':
cut = line.find('>')
tag = (line[1:] if cut < 0 else line[1 : cut]).strip().split()[0]
if f'</{tag}>' not in line:
@ -316,6 +316,7 @@ class QLocaleXmlWriter (object):
to each line."""
self.__rawOutput = self.__printit if save is None else save
self.__wrap = space
self.__write('<?xml version="1.0" encoding="UTF-8" ?>')
self.__openTag('localeDatabase', versionCldr = cldrVersion,
versionQt = qtVersion)