use URL-style string escaping
parent
e82b02b0e5
commit
a6e2edc475
Binary file not shown.
@ -1,31 +0,0 @@
|
||||
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