Reputation: 10925
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 ("\\u03bcs"
) doesn't work:
Upvotes: 2
Views: 536
Reputation: 48794
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.
Upvotes: 2
Reputation: 642
Try putting the escaped Unicode literal for the backslash itself, I think:
\u005c
Upvotes: 2