World of Warcraft Forever API · C_StringUtil.md, for your AI
C_StringUtil
14 functions, 1 tables, as Blizzard documents them for Forever 1.60.1 (70959).
Making an addon with an 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. It checks every call against this API before you try it in the game, then publishes it here. How it works.
Functions
C_StringUtil.CreateAbbreviatedNumberFormatter
formatter = C_StringUtil.CreateAbbreviatedNumberFormatter()
Creates a numeric formatter that converts numbers to abbreviated strings, eg. 123456 -> '123k'.
Returns
formatter | AbbreviatedNumberFormatter |
|---|
C_StringUtil.CreateNumericRuleFormatter
formatter = C_StringUtil.CreateNumericRuleFormatter()
Creates a numeric formatter that converts numbers to strings with flexible rulesets.
Returns
formatter | NumericRuleFormatter |
|---|
C_StringUtil.CreateSecondsFormatter
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
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
escapedText = C_StringUtil.EscapeLuaFormatString(text)
Returns a string with Lua format string tokens ('%') escaped.
Arguments
text | string |
|---|
Returns
escapedText | stringView |
|---|
C_StringUtil.EscapeLuaPatterns
escapedText = C_StringUtil.EscapeLuaPatterns(text)
Returns a string with all Lua pattern characters escaped.
Arguments
text | stringView |
|---|
Returns
escapedText | string |
|---|
C_StringUtil.EscapeQuotedCodes
escaped = C_StringUtil.EscapeQuotedCodes(text)
Returns a string with all quoted code sequences ('|' characters) escaped.
Arguments
text | string |
|---|
Returns
escaped | stringView |
|---|
C_StringUtil.FloorToNearestString
text = C_StringUtil.FloorToNearestString(number)
Arguments
number | number |
|---|
Returns
text | string |
|---|
C_StringUtil.RemoveContiguousSpaces
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
text = C_StringUtil.RoundToNearestString(number)
Arguments
number | number |
|---|
Returns
text | string |
|---|
C_StringUtil.StripHyperlinks
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
stripped = C_StringUtil.StripTextureMarkupForLooseFiles(text)
Arguments
text | string |
|---|
Returns
stripped | stringView |
|---|
C_StringUtil.TruncateWhenZero
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
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. |