Transforming text v0.1.0
Join
pub func Join(
allocator: Allocator,
parts: StringView[..],
separator: StringView
) -> String ! TextError
The text of every part of parts in order, with separator between each two.
No parts give empty text and one part gives that part, so the separator count is always one less than the parts.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
parts | StringView[..] | the pieces to join |
separator | StringView | what goes between them |
Returns: the joined text, or why it could not be made
ToUpper
pub func ToUpper(
allocator: Allocator,
view: StringView
) -> String ! TextError
The text of view in upper case by Unicode's full, unconditional mappings, so ß becomes SS and ʼn becomes
ʼN. The length may change.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
Returns: the text in upper case, or why it could not be made
ToLower
pub func ToLower(
allocator: Allocator,
view: StringView
) -> String ! TextError
The text of view in lower case by Unicode's full, unconditional mappings. A capital sigma always becomes σ,
never the final ς, since which one is right depends on the letters around it.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
Returns: the text in lower case, or why it could not be made
FoldCase
pub func FoldCase(
allocator: Allocator,
view: StringView
) -> String ! TextError
The text of view case-folded by Unicode's full folding, the form for comparing text without regard to case:
two texts that differ only in case fold to the same bytes, Straße and STRASSE included.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
Returns: the folded text, or why it could not be made
Concat
pub func Concat(
allocator: Allocator,
left: StringView,
right: StringView
) -> String ! TextError
The text of left followed by the text of right.
Fails with what went wrong; no partial text comes back.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
left | StringView | the first piece |
right | StringView | the second |
Returns: the two joined, or why they could not be
Repeat
pub func Repeat(
allocator: Allocator,
view: StringView,
count: uint
) -> String ! TextError
The text of view written count times.
A count of zero gives empty text, which is what makes repeating agree with joining: repeating twice is the
same as joining a thing to itself.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
count | uint | how many times |
Returns: the text repeated that many times, or why it could not be
Replace
pub func Replace(
allocator: Allocator,
view: StringView,
needle: StringView,
replacement: StringView
) -> String ! TextError
The text of view with every occurrence of needle replaced by replacement.
Occurrences are found left to right and never overlap, and what is put in their place is not searched again --
so replacing a with aa terminates rather than growing forever. An empty needle matches nothing, since the
alternative is a replacement between every pair of characters and before and after every one of them.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
needle | StringView | the text to look for |
replacement | StringView | the text to put in its place |
Returns: the text with every occurrence replaced, or why it could not be
IsAsciiLetter
pub func IsAsciiLetter(byte: char8) -> bool
Whether byte is an ASCII letter.
Parameters
| Name | Type | Description |
|---|---|---|
byte | char8 | the byte |
Returns: whether the byte is an ASCII letter
ToAsciiUpper
pub func ToAsciiUpper(
allocator: Allocator,
view: StringView
) -> String ! TextError
The text of view with every ASCII lower-case letter raised, and everything else left alone.
ASCII only: every byte above 0x7F passes through untouched, which is why this cannot change the length and
cannot produce anything that is not UTF-8.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
Returns: the text with its ASCII letters uppercased and everything else untouched
ToAsciiLower
pub func ToAsciiLower(
allocator: Allocator,
view: StringView
) -> String ! TextError
The text of view with every ASCII upper-case letter lowered.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
view | StringView | the borrowed text to act on |
Returns: the text with its ASCII letters lowercased and everything else untouched