fix: do not escape emoji

This commit is contained in:
Jan De Dobbeleer 2022-02-02 13:55:12 +01:00 committed by Jan De Dobbeleer
parent bfca351796
commit 566240c0ed
2 changed files with 3 additions and 1 deletions

View file

@ -194,7 +194,8 @@ func (cfg *Config) write(destination string) {
func escapeGlyphs(s string) string {
var builder strings.Builder
for _, r := range s {
if r < 0x1000 {
// exclude regular characters and emoji
if r < 0x1000 || r > 0x10000 {
builder.WriteRune(r)
continue
}

View file

@ -49,6 +49,7 @@ func TestEscapeGlyphs(t *testing.T) {
{Input: "\ue0b4", Expected: "\\ue0b4"},
{Input: "\ufd03", Expected: "\\ufd03"},
{Input: "}", Expected: "}"},
{Input: "🏚", Expected: "🏚"},
}
for _, tc := range cases {
assert.Equal(t, tc.Expected, escapeGlyphs(tc.Input), tc.Input)