toK3String

context(variableResolver: K3VariableResolver, markerPool: K3MutableMarkerPool)
fun String.toK3String(allowEscapedCodePoints: Boolean = true, allowEscapedMarkers: Boolean = true, allowStringVarRefs: Boolean = true): K3StringOrError(source)

Parses this string to a K3String, and interprets or disallows escaped codepoints, markers, and string variable references.

Note that K3Strings encode markers only by their marker pool-relative id. This means, if this function is called twice on the same string, but with different marker pools, the result might not be equal.

Return

The parsed K3String in the same normalization form as the input, or an error. If normalization is desired, normalize should be called on the resulting K3String.

Context Parameters

variableResolver

The contextual variable resolver, used for string variable reference resolution.

markerPool

The contextual marker pool, used for marker id allocation by name.

Parameters

allowEscapedCodePoints

Specifies if escaped code points in the bracketed hex format (\u{..hh}) format are allowed. If true, the escaped code points will behave as if the code point was directly present in the input string. If false, any encountered escaped code point sequence will be treated as an error.

allowEscapedMarkers

Specifies if markers (\m{..markerName}) are allowed. If true, any marker name will be allocated in the contextual markerPool and its id will be encoded as an atom in the resulting string. If false, any encountered marker sequence will be treated as an error.

allowStringVarRefs

Specifies if string variables (${..varId}) syntax is allowed. If true, the variable reference will be substituted using the contextual variableResolver. The substituted content is treated as a literal text. It is an error if the referenced variable does not exist. If false, any encountered variable ref syntax will be treated as an error.