Runestr is a library designed for manipulating strings at the rune level.
Functions
Length: Returns the count of Unicode code points (runes) within a string.
PadRight: Pads a string on the right side with a specified fill pattern until it reaches the provided width.
Left: Retrieves the leftmost n runes from a string.
Right: Retrieves the rightmost n runes from a string.
SplitOnNearestSpace: Divides a string into two parts at the nearest space character to the n-th position.
RuneAtPosition: Fetches the Unicode code point (rune) at the specified position in a string or returns the specified default value if the position is out of bounds.
Usage
import (
"github.com/tpfeiffer67/runestr"
)
License
This repository is licensed under the MIT License. See the LICENSE file for more information.
The runestr package offers several functions that operate
on strings at the rune level.
These functions allow for tasks such as calculating the length of a string (count the number of runes),
padding a string on the right side, etc.
PadRight pads a string on the right side with a fill pattern until it reaches the given width.
If the fill pattern doesn't fit exactly, the last character(s) of the fill pattern are repeated.
RuneAtPosition returns the Unicode code point (rune) at the specified position in a string,
or the specified default value if the position is out of bounds.
SplitOnNearestSpace splits a string into two parts at the nearest space character to the n-th position.
The first part includes all characters up to (but not including) the space character. If there is no space character, the word can be truncated.
The second part includes the rest of the stringwith leading and trailing spaces removed.