MCPcopy
hub / github.com/micro-editor/micro / CharacterCount

Function CharacterCount

internal/util/unicode.go:69–82  ·  view source on GitHub ↗

CharacterCount returns the number of characters in a byte array Similar to utf8.RuneCount but for unicode characters

(b []byte)

Source from the content-addressed store, hash-verified

67// CharacterCount returns the number of characters in a byte array
68// Similar to utf8.RuneCount but for unicode characters
69func CharacterCount(b []byte) int {
70 s := 0
71
72 for len(b) > 0 {
73 r, size := utf8.DecodeRune(b)
74 if !isMark(r) {
75 s++
76 }
77
78 b = b[size:]
79 }
80
81 return s
82}
83
84// CharacterCount returns the number of characters in a string
85// Similar to utf8.RuneCountInString but for unicode characters

Callers 15

DisplayMethod · 0.92
displayBufferMethod · 0.92
DisplayMethod · 0.92
getRowCountMethod · 0.92
CursorRightMethod · 0.92
InsertNewlineMethod · 0.92
BackspaceMethod · 0.92
GotoCmdMethod · 0.92
JumpCmdMethod · 0.92
EndMethod · 0.92
SearchMatchMethod · 0.92
DoTextEventMethod · 0.92

Calls 1

isMarkFunction · 0.70

Tested by

no test coverage detected