From 3088ba686ed3a4d1f37b43cab566a8c8c6c9729b Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 6 Jan 2017 17:40:26 +0100 Subject: [PATCH] [tools] Add C# strings encoding to resx2sr --- mcs/tools/resx2sr/resx2sr.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mcs/tools/resx2sr/resx2sr.cs b/mcs/tools/resx2sr/resx2sr.cs index feaaeb93e4c..c6051ba217e 100644 --- a/mcs/tools/resx2sr/resx2sr.cs +++ b/mcs/tools/resx2sr/resx2sr.cs @@ -102,7 +102,7 @@ public class Program str.WriteLine ("partial class SR"); str.WriteLine ("{"); foreach (var entry in txtStrings) { - str.Write ($"\tpublic const string {entry.Item1} = \"{entry.Item2}\";"); + str.Write ($"\tpublic const string {entry.Item1} = \"{ToCSharpString (entry.Item2)}\";"); if (!string.IsNullOrEmpty (entry.Item3)) str.Write (" // {entry.Item3}"); @@ -114,6 +114,13 @@ public class Program } } + static string ToCSharpString (string str) + { + str = str.Replace ("\n", "\\n"); + + return str.Replace ("\\", "\\\\").Replace ("\"", "\\\""); + } + static bool LoadStrings (List> resourcesStrings, List files) { var keys = new Dictionary (); -- 2.11.4.GIT