# C_StringUtil: World of Warcraft Forever API

Forever 1.60.1 (70959), Interface 16001, Lua 5.1, from Blizzard's own API documentation. Page: https://wowaddons.gg/forever-api/C_StringUtil

## Functions

### C_StringUtil.CreateAbbreviatedNumberFormatter

```lua
formatter = C_StringUtil.CreateAbbreviatedNumberFormatter()
```

Creates a numeric formatter that converts numbers to abbreviated strings, eg. 123456 -> '123k'.

Returns:
- `formatter`: AbbreviatedNumberFormatter

### C_StringUtil.CreateNumericRuleFormatter

```lua
formatter = C_StringUtil.CreateNumericRuleFormatter()
```

Creates a numeric formatter that converts numbers to strings with flexible rulesets.

Returns:
- `formatter`: NumericRuleFormatter

### C_StringUtil.CreateSecondsFormatter

```lua
formatter = C_StringUtil.CreateSecondsFormatter()
```

Creates a numeric formatter that converts numbers measuring durations in seconds to strings, eg. 93 -> '1m 33s'.

Returns:
- `formatter`: SecondsFormatter

### C_StringUtil.EscapeDecimalNonPrintables

```lua
escapedText = C_StringUtil.EscapeDecimalNonPrintables(text)
```

Returns a string with ASCII control characters (except , , and 	) and invalid UTF-8 bytes replaced by decimal escape sequences (e.g. \127).

Arguments:
- `text`: stringView

Returns:
- `escapedText`: string

### C_StringUtil.EscapeLuaFormatString

```lua
escapedText = C_StringUtil.EscapeLuaFormatString(text)
```

Returns a string with Lua format string tokens ('%') escaped.

Arguments:
- `text`: string

Returns:
- `escapedText`: stringView

### C_StringUtil.EscapeLuaPatterns

```lua
escapedText = C_StringUtil.EscapeLuaPatterns(text)
```

Returns a string with all Lua pattern characters escaped.

Arguments:
- `text`: stringView

Returns:
- `escapedText`: string

### C_StringUtil.EscapeQuotedCodes

```lua
escaped = C_StringUtil.EscapeQuotedCodes(text)
```

Returns a string with all quoted code sequences ('|' characters) escaped.

Arguments:
- `text`: string

Returns:
- `escaped`: stringView

### C_StringUtil.FloorToNearestString

```lua
text = C_StringUtil.FloorToNearestString(number)
```

Arguments:
- `number`: number

Returns:
- `text`: string

### C_StringUtil.RemoveContiguousSpaces

```lua
trimmedText = C_StringUtil.RemoveContiguousSpaces(text, maxAllowedSpaces)
```

Returns a string with all contiguous occurrences of ASCII space characters truncated.

Arguments:
- `text`: stringView
- `maxAllowedSpaces`: number. Maximum number of permitted contiguous space characters; excessive spaces will be truncated to this count.

Returns:
- `trimmedText`: string

### C_StringUtil.RoundToNearestString

```lua
text = C_StringUtil.RoundToNearestString(number)
```

Arguments:
- `number`: number

Returns:
- `text`: string

### C_StringUtil.StripHyperlinks

```lua
stripped = C_StringUtil.StripHyperlinks(text, [maintainColor], [maintainBrackets], [stripNewlines], [maintainAtlases], [maintainTextures])
```

Arguments:
- `text`: string
- `maintainColor`: bool, default false. If true, preserve all '|c' and '|r' quoted code sequences.
- `maintainBrackets`: bool, default false. If true, preserve all '[' and ']' characters.
- `stripNewlines`: bool, default false. If true, remove all '|n' quoted code sequences.
- `maintainAtlases`: bool, default false. If true, preserve all balanced '|A' and '|a' quoted code sequences.
- `maintainTextures`: bool, default false. If true, preserve all balanced '|T' and '|t' quoted code sequences.

Returns:
- `stripped`: stringView

### C_StringUtil.StripTextureMarkupForLooseFiles

```lua
stripped = C_StringUtil.StripTextureMarkupForLooseFiles(text)
```

Arguments:
- `text`: string

Returns:
- `stripped`: stringView

### C_StringUtil.TruncateWhenZero

```lua
text = C_StringUtil.TruncateWhenZero(number)
```

Formats the given number to a string as an integer (rounding down). If the integer is zero, returns an empty string.

Arguments:
- `number`: number

Returns:
- `text`: string

### C_StringUtil.WrapString

```lua
text = C_StringUtil.WrapString(infix, [prefix], [suffix])
```

Returns a string with 'prefix' and 'suffix' joined to 'infix' iif 'infix' is not an empty string. Else, an empty string is returned.

Arguments:
- `infix`: stringView
- `prefix`: stringView, may be nil
- `suffix`: stringView, may be nil

Returns:
- `text`: string

## Tables

### StripHyperlinkOptions (structure)

- `maintainColor`: bool, default false. If true, preserve all '|c' and '|r' quoted code sequences.
- `maintainBrackets`: bool, default false. If true, preserve all '[' and ']' characters.
- `stripNewlines`: bool, default false. If true, remove all '|n' quoted code sequences.
- `maintainAtlases`: bool, default false. If true, preserve all balanced '|A' and '|a' quoted code sequences.
- `maintainTextures`: bool, default false. If true, preserve all balanced '|T' and '|t' quoted code sequences.

---
Make an addon with your AI: tell it "Read https://wowaddons.gg/agents.md, then make me a World of Warcraft Forever addon that …, try it with me in the game, and publish it."
