DecodeCharacterInString returns the next character from a string A character is a rune along with any accompanying combining runes
(str string)
| 48 | // DecodeCharacterInString returns the next character from a string |
| 49 | // A character is a rune along with any accompanying combining runes |
| 50 | func 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 |
| 65 | } |
| 66 | |
| 67 | // CharacterCount returns the number of characters in a byte array |
| 68 | // Similar to utf8.RuneCount but for unicode characters |
no test coverage detected