Files
openchamber-android-native/third_party/mygo/internal/platform/text_input_runes.go
T

16 lines
285 B
Go
Raw Normal View History

package platform
import "unicode/utf16"
// RunesInUTF16 returns how many runes of s the first units UTF-16 units hold.
func RunesInUTF16(s string, units int) int {
n := 0
for _, r := range s {
if units <= 0 {
break
}
units -= max(utf16.RuneLen(r), 1)
n++
}
return n
}