File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,18 @@ def update_xml_file(resource: AndroidResourceFile) -> None:
258258
259259 try :
260260 tree .write (resource .path , encoding = "utf-8" , xml_declaration = True )
261+ # Post-process the file to replace single quotes with double quotes in the XML declaration.
262+ with open (resource .path , "r+" , encoding = "utf-8" ) as f :
263+ content = f .read ()
264+ # Replace the XML declaration that uses single quotes with one using double quotes.
265+ content = re .sub (
266+ r'^<\?xml version=\'1\.0\' encoding=\'utf-8\'\?>' ,
267+ '<?xml version="1.0" encoding="utf-8"?>' ,
268+ content
269+ )
270+ f .seek (0 )
271+ f .write (content )
272+ f .truncate ()
261273 logger .info (f"Updated XML file: { resource .path } " )
262274 except Exception as e :
263275 logger .error (f"Error writing XML file { resource .path } : { e } " )
You can’t perform that action at this time.
0 commit comments