MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

escape-sequences in strings

  • To: mathgroup at
  • Subject: [mg15849] escape-sequences in strings
  • From: Timo Felbinger <timof at>
  • Date: Fri, 12 Feb 1999 18:40:10 -0500 (EST)
  • Organization: University of Potsdam
  • Sender: owner-wri-mathgroup at


I am currently working on a front end (in C) for Mathematica, which
passes user-defined input via mathlink to the Mathematica kernel for

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 Felbinger   <Timo.Felbinger at> Quantum
Physics Group
Institute of Physics
University of Potsdam, Germany

  • Prev by Date: Re: BracketingBar for output
  • Next by Date: Re: Piecewise integration of f[x,y]
  • Previous by thread: RE: Mathematica vs. Executable code
  • Next by thread: Re: escape-sequences in strings