Skip to content

Commit

Permalink
Revert bytes.ReplaceAll for backward-compatibility with Go 1.11 (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
n10v authored Feb 9, 2023
1 parent 527ad3f commit 997e77f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion v2/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ func decodeText(src []byte, from Encoding) string {
// See https://apps.timwhitlock.info/unicode/inspect?s=%EF%BF%BD.
// See https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8.
if from.Equals(EncodingUTF16) {
result = bytes.ReplaceAll(result, []byte{0xEF, 0xBF, 0xBD}, []byte{})
// bytes.Replace(s, old, new, -1) is the same as bytes.ReplaceAll(s, old, new),
// but bytes.ReplaceAll is only added in Go 1.12.
result = bytes.Replace(result, []byte{0xEF, 0xBF, 0xBD}, []byte{}, -1)
}

return string(result)
Expand Down

0 comments on commit 997e77f

Please sign in to comment.