a way to escape strings for export
- To: mathgroup at smc.vnet.net
- Subject: [mg66050] a way to escape strings for export
- From: "Chris Chiasson" <chris.chiasson at gmail.com>
- Date: Thu, 27 Apr 2006 05:45:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
(the first line is needed, because it trips something inside
Mathematica that defines the generateNumericEntityFromCharacterCode
function)
this is useful for XML, XHTML, etc export
In[1]:=
XML`MathML`BoxesToMathML["\[Beta]"];
In[2]:=
escapeStringXML[strxpr_String]:=
Apply[StringJoin,
If[Or[33\[LessEqual]#\[LessEqual]127,#\[Equal]10],FromCharacterCode[#],
System`Convert`XMLDump`generateNumericEntityFromCharacterCode@#]&/@
ToCharacterCode[strxpr]]
In[3]:=
escapeStringXML["\[Beta]\[Alpha]+1-2g\[Zeta]"]
Out[3]=
βα+1-2gζ