only need to dupe string for zalgo if zerowidth present
Ted Unangst tedu@tedunangst.com
Thu, 25 Apr 2019 10:59:57 -0400
1 files changed,
20 insertions(+),
9 deletions(-)
jump to
M
skulduggery.go
→
skulduggery.go
@@ -70,19 +70,30 @@ }
return string(x) } s = re_alltheshitz.ReplaceAllStringFunc(s, fixer) - x := make([]byte, 0, len(s)) + zw := false for _, c := range s { if runewidth.RuneWidth(c) == 0 { - if zw { - continue + zw = true + break + } + } + if zw { + x := make([]byte, 0, len(s)) + zw = false + for _, c := range s { + if runewidth.RuneWidth(c) == 0 { + if zw { + continue + } + zw = true + } else { + zw = false } - zw = true - } else { - zw = false + q := string(c) + x = append(x, []byte(q)...) } - q := string(c) - x = append(x, []byte(q)...) + return string(x) } - return string(x) + return s }