Fix overlapping text and add text escaping
parent
ea8c069d68
commit
e82b02b0e5
Binary file not shown.
@ -0,0 +1,31 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ConformalDecals.Text {
|
||||||
|
public static class TextEncoder {
|
||||||
|
private static readonly Dictionary<string, string> _escapeSequences = new Dictionary<string, string>() {
|
||||||
|
{"\n", "\\n"},
|
||||||
|
{"\\", "\\\\"},
|
||||||
|
{"/", "\\/"},
|
||||||
|
{"=", "\\="}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static string Encode(string input) {
|
||||||
|
var builder = new StringBuilder(input);
|
||||||
|
foreach (var escapePair in _escapeSequences) {
|
||||||
|
builder.Replace(escapePair.Key, escapePair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Decode(string input) {
|
||||||
|
var builder = new StringBuilder(input);
|
||||||
|
foreach (var escapePair in _escapeSequences) {
|
||||||
|
builder.Replace(escapePair.Value, escapePair.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue