In my Java application I want to output striked letters (like html tag do). Is there any way to do 开发者_高级运维this using Unicode (combine )
You can use U+0336, the combining long stroke overlay, to accomplish this task.
The official Combining Diacritical Marks unicode chart lists "strikethrough" as an 'informative alias', meaning that this is is the official specified purpose of this character.
0336 ̶◌ COMBINING LONG STROKE OVERLAY
= strikethrough
• connects on left and right
For comparison, here is U+0336 compared to the html <strike>
tag:
U̶n̶i̶c̶o̶d̶e ̶c̶o̶m̶b̶i̶n̶i̶n̶g̶ ̶l̶o̶n̶g̶ ̶s̶t̶r̶o̶k̶e̶ ̶o̶v̶e̶r̶l̶a̶y̶
Hypertext strike tag
Note that many font rendering engines do not render U+0336 correctly, and when possible one should use markup formatting or another mechanism. Depending on your browser, the above text likely has a large gap in the line around the "m" in combining, and @Alex78191 reports that it renders so low for them that it looks more like an underline than a strikethrough. For this reason, one should still prefer HTML another markup technology over U+0336 for this purpose, given the option.
No, this is not possible. While there is the concept of a stroke as diacritic, it's not available as a separate Unicode character, probably because the various letters that use a stroke diacritic do not place it at the same height or even angle. So the result would not resemble strikethrough markup anyway.
To output strikethrough text in Java, you need to use an output format that allows you to use explicit markup. If you have a Swing app, you're in luck as many Swing components support HTML. Otherwise it depends on what presentation technology you're using.
As said before, Unicode doesn't do that, but a lot of Swing components understand basic HTML tags.
JLabel label = new JLabel("<html><s>My stroke</s></html>")
No. Unicode does not define a combining strikeout mark. Unicode's view is that this is the job of markup -- like HTML.
精彩评论