I'm writing an SML program and I'm trying to convert a string that has escape sequences into a string that does not have escape sequences.
I've tried this, but it doesn't seem to work (prints just "Hello "
)
fun test x =
let val esc = "Hello \\ Bob \n Newman"
val fixed = String.fromString esc
in
print (valOf(fixed))
end
I think I might have to use the String.scan
function however, I don't exactly understand how it works.
The function signature is
scan : (char, 'a) StringCvt.reader
-> (string, 'a) StringCvt.reader
So I have a few questions:
1) Can you expalin what exactly this scan signature is saying...What arguments does the function take and what does it return
2) Is this the function that I should be using?
3) Can you give me any guidance on using this function. Thanks
EDIT: Ok, so the above example I simplified, but I may have simplified it too much...Here's exactly what I'm doing. I'm have a global string called str
and and input stream of chars/strings...As I read the input stream, I concatenate str
with the character that I just read. After I have read all of the characters, I want to return str
but with all of the escape sequences converted.