Documentation ¶
Overview ¶
pkg `runes` is the golang lib package for runes, which is inspired by standard lib `strings`.
Although `strings` and `unicode/utf8` pkg is great, but some of them are behaving weirdly.
For example,
- If the byte slice is incomplete, then `utf8.CountXXX` counts the length of bytes and add them.
- `strings.Index` returns `0` if passing empty string `""` to its parameter `substr`.
With this pkg, these points are fixed.
Index ¶
Constants ¶
const MAX_BYTE_UTF8 = 6 // 6 is the max value of utf8 byte
Variables ¶
This section is empty.
Functions ¶
func Before ¶
Before returns the byte start position of before valid rune. If the before valid rune is not found, returns given bytepos.
func Count ¶
Count returns the number of str in rune. If bytecnt >= 0, then counts str[:bytescnt]. If bytecnt < 0 (mostly -1), then counts all the str.
func CountByte ¶
Count returns the number of str to runecnt in byte. If runecnt >= 0, then counts str[:runecnt]. If runecntj < 0 (mostly -1), then counts all the str.
Types ¶
This section is empty.