I'm writing Javadoc for a class explaining proper unicode escaping:
* String unitAbbrev = "μs"; //Best: perfectly clear even without a comment.
* String unitAbbrev = "\u03bcs"; //Poor: the reader has no idea what this is.
Unfortunately they both render with "μs":
Is there any way to escape this unicode escape?
Double backslash ( "\\\μs"
) doesn't work:
Try putting the escaped Unicode literal for the backslash itself, I think:
\\
You can alternatively use the HTML escape \
, which still isn't great when read from source, but it's at least clearly not a unicode escape.
The only disadvantage of HTML escapes is they don't work inside {@code ...}
blocks (they're rendered verbatim), so you need to use <pre>
and <code>
instead.
It seems like \\\\
should work as javac
appears to handle it correctly, but javadoc
isn't.
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.