dparse.strings

Utility for unescaping D string literals of any kind

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

fnbool 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.
fnbool isStringLiteral(const(char)[] literal)ditto
fnstring 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 fnstring unescapeDoubleQuotedContent( InvalidEscapeAction invalidEscapeAction = InvalidEscapeAction.error )( string input )
private fnstring parseHexStringContent( InvalidEscapeAction invalidEscapeAction = InvalidEscapeAction.error )( string input )
private fnint parseHexChar(char c)
private fnbool isIdentifierChar(char c)
private fnstring normalizeNewLines(string text)normalizes all line endings with \n, as parsed in D strings