mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
fix bug in bytes.Map and add test cases for Map in both strings and bytes packages.
thanks to ulrik.sverdrup for the test case. Fixes #191. R=rsc CC=golang-dev https://golang.org/cl/155056
This commit is contained in:
parent
13ad5d40c4
commit
27779dd6cb
3 changed files with 56 additions and 3 deletions
|
|
@ -220,9 +220,7 @@ func Map(mapping func(rune int) int, s []byte) []byte {
|
|||
for i := 0; i < len(s); {
|
||||
wid := 1;
|
||||
rune := int(s[i]);
|
||||
if rune < utf8.RuneSelf {
|
||||
rune = mapping(rune)
|
||||
} else {
|
||||
if rune >= utf8.RuneSelf {
|
||||
rune, wid = utf8.DecodeRune(s[i:len(s)])
|
||||
}
|
||||
rune = mapping(rune);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue