It’s easy so declare a raw string
String raw = @'\"Hello\"';
But how can I convert a existing string to a raw string ?
This can come with file reading or ajax call : I want read the file as a raw string but the readAsText method give me a no raw string.
I tryied thing like :
String notRaw = '\"Hello\"';
String raw = @raw;
But not compiling.
How can I do this?
EDIT : My need is to read the string char by char. So I don’t want to read \” as one char ” but as two chars \ and “
If you want to read a file without interpreting escape characters, then you need to
readAsBytes, which will give you a list of characters as integers. You can then detect a backslash and quote as:You then pass the desired substrings to a string constructor: