MathGroup Archive 2004

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

Search the Archive

writing greek characters to files

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46846] writing greek characters to files
  • From: semorrison_ at hotmail.com (Scott Morrison)
  • Date: Wed, 10 Mar 2004 04:57:43 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I'm writing a package in which I need to save the results of various
long calculations.

I wrote two simple functions;

ToStringHeld[expr_]:=StringTake[ToString[Hold[expr],InputForm],{6,-2}]

SetAttributes[{DefinitionString},{HoldAll}]

DefinitionString[expr_]:=ToStringHeld[expr] <> " = " <>
   ToString[expr,InputForm] <> ";\n"

Now, for example, with

b=6;

DefinitionString[b] produces the string "b = 6;\n". Great. I then
write it to a file with, for example

stream=OpenWrite["tmp"];
WriteString[stream, DefinitionString[b]];
Close["tmp"];

I run into problems if in the example above I replace b everywhere
with beta (entered as <esc>b<esc> in the front-end). In this case the
file "tmp" contains an unprintable character (pair of characters, in
fact), whereas I'd like it to contain \[Beta] = 6;.

If I use instead DefinitionString[\[Beta]]>>"tmp", it correctly prints
the string, but with quotation marks, making it useless for input...

Any suggestions?

Thanks, Scott Morrison


  • Prev by Date: Found my While problem
  • Next by Date: Re: append to a file
  • Previous by thread: Found my While problem
  • Next by thread: Re: writing greek characters to files