Skip to content

Commit 671df49

Browse files
committed
Fix xml output
whitespace now preserved, xml-invalid characters present in reach/h4/h2a no longer throw an exception. Updated version in UI.
1 parent 3d01dc2 commit 671df49

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

MCCLocalizationEditor/LocalizationData.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ public static List<LocalizationPair> ReadXMLFile(string path)
136136
{
137137
string content = entry.InnerText;
138138

139-
//h3 terminals contain a weird character that xml doesn't support, could be more?
140-
string refilt = content.Replace("\\f", "\f");
139+
//check for known weird characters and unescape them
140+
string refilt = content.Replace("\\a", "\a")
141+
.Replace("\\b", "\b")
142+
.Replace("\\f", "\f");
141143

142144
if (entry.Attributes["key"] != null)
143145
{
@@ -180,9 +182,12 @@ public static void SaveXMLFile(string path, List<LocalizationPair> strings)
180182
foreach (LocalizationPair entry in strings)
181183
{
182184
writer.WriteStartElement("entry");
185+
writer.WriteAttributeString("xml", "space", null, "preserve");
183186
writer.WriteAttributeString("keyHash", entry.KeyHash.ToString());
184-
//h3 terminals contain a weird character that xml doesn't support, could be more?
185-
string filt = entry.String.Replace("\f", "\\f");
187+
//check for known weird characters and escape them
188+
string filt = entry.String.Replace("\a", "\\a")
189+
.Replace("\b", "\\b")
190+
.Replace("\f", "\\f");
186191
writer.WriteValue(filt);
187192
writer.WriteEndElement();
188193
}

MCCLocalizationEditor/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
HorizontalAlignment="Left" VerticalAlignment="Center" Margin="4" Grid.Row="3" />
9292

9393
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="4" Grid.Row="3">
94-
MCC Localization Editor v1 by Zeddikins.
94+
MCC Localization Editor v1.0a by Zeddikins.
9595
<Hyperlink NavigateUri="https://github.com/Lord-Zedd/MCCLocalizationEditor" RequestNavigate="Hyperlink_RequestNavigate">
9696
GitHub
9797
</Hyperlink>

0 commit comments

Comments
 (0)