escape-sequences in strings
- To: mathgroup at smc.vnet.net
- Subject: [mg15849] escape-sequences in strings
- From: Timo Felbinger <timof at uranos.quantum.physik.uni-potsdam.de>
- Date: Fri, 12 Feb 1999 18:40:10 -0500 (EST)
- Organization: University of Potsdam
- Sender: owner-wri-mathgroup at wolfram.com
Hello, I am currently working on a front end (in C) for Mathematica, which passes user-defined input via mathlink to the Mathematica kernel for evaluation. It works fine for most input, but if there is a double-quoted string in the input which contains escape sequences, funny things happen: '"hello\\world"' will return 'hello\\world' '"hello\nworld"' will return 'hello world' '"hello\world"' will return nothing and seems to freeze the kernel '"hello\"world"' will return a syntax error '"hello\"world\""' will return '2', a linefeed, and ' hello world' In these examples, everything enclosed by single quotes is to be read literally (ie all double quotes and backslashes were sent as is). The input was transfered via MLPutString as an argument of EnterTextPacket, and the results are the payload of a RETURNTEXTPKT, received via MLGetSTring. This behaviour seems to contradict what the mathematica book says about escape sequences inside double-quoted strings. What am I missing here? Is the front end responsible for the expansion of backslash escape sequences, and if so, in what way? BTW, where can I find the "MathLink Reference Manual" which is cited in Todd Gayley's mathlink tutorial? The "DeveloperGuide.nb" on my Mathematica CD isn't really helpful. Timo -- Timo Felbinger <Timo.Felbinger at quantum.physik.uni-potsdam.de> Quantum Physics Group Institute of Physics University of Potsdam, Germany