OSDN Git Service

Altered TSV encoding to use special ASCII
authormelchior <melchior@users.osdn.me>
Sun, 14 Feb 2021 21:52:58 +0000 (16:52 -0500)
committermelchior <melchior@users.osdn.me>
Sun, 14 Feb 2021 21:52:58 +0000 (16:52 -0500)
Keeping whitespace char in raw data
Metadata.js using standard JSON  encoding
(removing single quote)

Automap/Designators/DefaultDesignators.cs
Automap/Subsystems/AutomapSystem.cs
Automap/Subsystems/JsonGenerator.cs

index 41bd4af..ec6b2c7 100644 (file)
@@ -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,
                                                        }
                                                        );
-
                        }
                }
 
index eb59630..3482ded 100644 (file)
@@ -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");
index f215979..a6e593a 100644 (file)
@@ -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)); }
                                                        }
                                                );
                                        });