dparse.strings
Utility for unescaping D string literals of any kind
enum InvalidEscapeAction
Types 1
Defines different handler types what to do when invalid escape sequences are found inside unescapeString.
keep = 0keep the backslash character as well as the escape characters in the string like in the input string.
skipIgnore and skip offending characters, drop them from the output. Named character entities are still being included like keep as they are not currently implemented.
errorThrow a ConvException on invalid escape sequences. Does not throw anything on unknown named character entities as they are not currently implemented but instead treats them like keep.
Functions 8
fn
bool isStringLiteral(const(char)[] literal, out char stringCloseChar,
out bool hasPostfix, out bool parseEscapes, out int prefixLength)Checks if a string literal input has correct start/end sequences (quotes) to be any kind of D string literal.fn
string unescapeString(
InvalidEscapeAction invalidEscapeAction = InvalidEscapeAction.error
)(
string input
)Unescapes a D string, effectively being the same as mixing in the string into some function call, but only for single string literals.private fn
string unescapeDoubleQuotedContent(
InvalidEscapeAction invalidEscapeAction = InvalidEscapeAction.error
)(
string input
)private fn
string parseHexStringContent(
InvalidEscapeAction invalidEscapeAction = InvalidEscapeAction.error
)(
string input
)private fn
string normalizeNewLines(string text)normalizes all line endings with \n, as parsed in D strings