@@ -29,39 +29,15 @@ func isMark(r rune) bool {
2929// DecodeCharacter returns the next character from an array of bytes
3030// A character is a rune along with any accompanying combining runes
3131func DecodeCharacter (b []byte ) (rune , []rune , int ) {
32- r , size := utf8 .DecodeRune (b )
33- b = b [size :]
34- c , s := utf8 .DecodeRune (b )
35-
36- var combc []rune
37- for isMark (c ) {
38- combc = append (combc , c )
39- size += s
40-
41- b = b [s :]
42- c , s = utf8 .DecodeRune (b )
43- }
44-
45- return r , combc , size
32+ combc , size := DecodeCombinedCharacter (b )
33+ return combc [0 ], combc [1 :], size
4634}
4735
4836// DecodeCharacterInString returns the next character from a string
4937// A character is a rune along with any accompanying combining runes
5038func DecodeCharacterInString (str string ) (rune , []rune , int ) {
51- r , size := utf8 .DecodeRuneInString (str )
52- str = str [size :]
53- c , s := utf8 .DecodeRuneInString (str )
54-
55- var combc []rune
56- for isMark (c ) {
57- combc = append (combc , c )
58- size += s
59-
60- str = str [s :]
61- c , s = utf8 .DecodeRuneInString (str )
62- }
63-
64- return r , combc , size
39+ combc , size := DecodeCombinedCharacterInString (str )
40+ return combc [0 ], combc [1 :], size
6541}
6642
6743// DecodeCombinedCharacter returns the next combined character
0 commit comments