简体   繁体   中英

Display non-ASCII character in ImageJ

Simple question but I can't find the answer anywhere. No search strategy so far has worked for me.

I have an ImageJ macro that opens a dialog for users to set the size of an image overlay. The dialog prompts users to provide the size of the overlay in microns:

Dialog.addNumber("Width (µm):", 500);
Dialog.addNumber("Height (µm):", 250);

The problem is that the dialog doesn't display as expected: There is an extra character printed in front of the micron symbol. Instead of this (µm), I get this (¬µm).

It's a character encoding issue, clearly. But I can't find any documentation anywhere telling me how to properly insert a non-ASCII character into an ImageJ dialog. I've tried using ASCII code (230) and Unicode (U+00B5) in every way I can think of, but in those cases it simply renders as code rather than a symbol. There are macro calls in ImageJ to obtain a Unicode string for a character, but there is no way to print it back except as a string of numbers? I'm stumped.

What you do is this:

Dialog.addNumber("Width (" + fromCharCode(181) + "m):", 500);
Dialog.addNumber("Height (" + fromCharCode(181) + "m):", 250);

where 181 is the decimal value of hexidecimal 00B5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM