From 8db4cb4299370039bcbf0894e24f368100789c5b Mon Sep 17 00:00:00 2001 From: melchior Date: Sun, 14 Feb 2021 16:52:58 -0500 Subject: [PATCH] Altered TSV encoding to use special ASCII Keeping whitespace char in raw data Metadata.js using standard JSON encoding (removing single quote) --- Automap/Designators/DefaultDesignators.cs | 11 +++-------- Automap/Subsystems/AutomapSystem.cs | 4 ++-- Automap/Subsystems/JsonGenerator.cs | 8 ++++++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Automap/Designators/DefaultDesignators.cs b/Automap/Designators/DefaultDesignators.cs index 41bd4af..ec6b2c7 100644 --- a/Automap/Designators/DefaultDesignators.cs +++ b/Automap/Designators/DefaultDesignators.cs @@ -13,9 +13,7 @@ using Vintagestory.GameContent; namespace Automap { public static class DefaultDesignators - { - private static Regex stripControlChars = new Regex(@"\s", RegexOptions.Multiline); - + { public static BlockDesignator Roads = new BlockDesignator( new AssetLocation("game", "stonepath"), @@ -104,13 +102,11 @@ namespace Automap Name = "Sign", PrettyLocation = posn.PrettyCoords(clientAPI), Location = posn.Copy(), - Notes = stripControlChars.Replace(signEntity.text, " "), + Notes = signEntity.text, Timestamp = DateTime.UtcNow, } ); - } - } @@ -131,11 +127,10 @@ namespace Automap Name = "Signpost", PrettyLocation = posn.PrettyCoords(clientAPI), Location = posn.Copy(), - Notes = stripControlChars.Replace(string.Join(",", signEntity.textByCardinalDirection), " "), + Notes = string.Join(",", signEntity.textByCardinalDirection), Timestamp = DateTime.UtcNow, } ); - } } diff --git a/Automap/Subsystems/AutomapSystem.cs b/Automap/Subsystems/AutomapSystem.cs index eb59630..3482ded 100644 --- a/Automap/Subsystems/AutomapSystem.cs +++ b/Automap/Subsystems/AutomapSystem.cs @@ -422,7 +422,7 @@ namespace Automap { tsvWriter.Write(point.Name + "\t"); var notes = point.Notes - .Replace("\n", "\\n") + .Replace('\n', '\x001f') .Replace("\t", "\\t") .Replace("\\", "\\\\"); tsvWriter.Write(notes + "\t"); @@ -436,7 +436,7 @@ namespace Automap { tsvWriter.Write(entity.Name + "\t"); var notes = entity.Notes - .Replace("\n", "\\n") + .Replace('\n', '\x001f') .Replace("\t", "\\t") .Replace("\\", "\\\\"); tsvWriter.Write(notes + "\t"); diff --git a/Automap/Subsystems/JsonGenerator.cs b/Automap/Subsystems/JsonGenerator.cs index f215979..a6e593a 100644 --- a/Automap/Subsystems/JsonGenerator.cs +++ b/Automap/Subsystems/JsonGenerator.cs @@ -120,8 +120,12 @@ namespace Automap $"{poi.Location.X}_{poi.Location.Z}", PointsOfInterest_Vals, (mem) => { - var dasField = GetValue(mem, poi); - jsonWriter.WriteRawValue(JsonConvert.SerializeObject(dasField)); + var dasField = GetValue(mem, poi); + if (Type.GetTypeCode(mem.GetType( )) == TypeCode.String) { + string dasString = dasField as string; + jsonWriter.WriteValue(dasString.Replace('\'', ' ')); + } + else { jsonWriter.WriteRawValue(JsonConvert.SerializeObject(dasField)); } } ); }); -- 2.11.0