correctly show files with special chars in commit

This commit is contained in:
mjarkk
2021-07-23 12:04:23 +02:00
parent 9a087d04eb
commit fc76b44b45
5 changed files with 47 additions and 14 deletions
+12
View File
@@ -32,3 +32,15 @@ func NormalizeLinefeeds(str string) string {
str = strings.Replace(str, "\r", "", -1)
return str
}
// EscapeSpecialChars - Replaces all special chars like \n with \\n
func EscapeSpecialChars(str string) string {
return strings.NewReplacer(
"\n", "\\n",
"\r", "\\r",
"\t", "\\t",
"\b", "\\b",
"\f", "\\f",
"\v", "\\v",
).Replace(str)
}