plist-cil
plist-cil copied to clipboard
SaveToXml adding Byte Order Mark
When using PropertyListParser.SaveAsXml();
the output is an xml with the Byte Order Mark (BOM) which are non ASCII characters.
I made a simple test of loading a binary Info.plist and the just save the same content but into an XML.
The result
vis ~/Desktop/temp.plist
\M-o\M-;\M-?<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
Instead of
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
This brings a lot of problem later, specially with fastlane
.
A Fix
This method is using Encoding.UTF8
public static void SaveAsXml(NSObject root, Stream outStream)
{
using var w = new StreamWriter(outStream, Encoding.UTF8, 1024, true);
w.Write(root.ToXmlPropertyList());
}
It should be using
public static void SaveAsXml(NSObject root, Stream outStream)
{
var utf8Encoding = new UTF8Encoding(false);
using var w = new StreamWriter(outStream, utf8Encoding, 1024, true);
w.Write(root.ToXmlPropertyList());
}
This is enough to save the xml in the correct form.