Posted by
Michael Schmid on
Mar 25, 2013; 6:02pm
URL: http://imagej.273.s1.nabble.com/Macro-language-and-non-ASCII-characters-tp5002388p5002393.html
Hi Michael,
no such problem on Mac OS X or Wine (emulated Windows on OS X):
setResult("with space", 0, 1);
setResult("Vol. (µm³)", 0, 2);
getResult("with space", 0); //gives 1 in the Log window
getResult("Vol. (µm³)", 0); //gives 2
Note, however, that spaces or tabs should be avoided in column names - there are cases where spaces or tabs cause a problem, e.g.
http://rsb.info.nih.gov/ij/macros/examples/PrintResults.txtConcerning special characters: Java uses unicode, there should be no problems with it, but there are a few pitfalls:
For the 'µ' character, there are a few possibilities in Unicode, the Micro Sign 00B5, the greek mu 03BC, and more in the extended set of math alphanumeric symbols. In your email, it looks like the Micro Sign 00B5, but I don't know what you have in the column header.
If you have a macro file, make sure that file.encoding in Plugins>Utilities>ImageJ Properties matches the encoding of the file (does ImageJ display the macro correctly when opened in a text window?). To avoid file encoding problems, usually it is best to use only ascii characters in macros and Java sourcecode. Instead of the special characters, use the fromCharCode macro function:
muChar = fromCharCode(0xb5);
cubeChar = fromCharCode(0xb3);
getResult("Vol. ("+ muChar +"m"+ cubeChar +")", 0);
Michael
________________________________________________________________
On Mar 25, 2013, at 18:08, Doube, Michael wrote:
> Dear all,
>
> It seems like non-ASCII characters aren't handled by the macro interpreter, maybe in a platform-dependent way.
>
> Most recently, this macro code gives a NaN result instead of the correct value from the table:
>
> a = getResult("Vol. (µm³)", 0);
> print(a);
>
> After running BoneJ's Analyse Particles command. Seems like the ³ breaks it. Previously I broke the macro language by putting a ü in a menu item.
>
> I had a look into the code and fail to see the source of the breakage. Can I make a request that someone more enlightened points me towards the right spot, or somehow makes the macro language understand Unicode?
>
> Michael
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html