Search code examples
javaregexcharacter-encodingcontrol-characters

Do control characters have graphic character equivalent?


I came across a VT(Vertical Tab) character, when I searched for this character I found that its ascii code is 11 and its male symbol(♂). When I try to test a the character with regex \{Cntrl}in java using the matches function in java, I can see that it detects VT as a control character but does not detect male symbol as control character.

From this I could understand that both VT character and male symbol(♂) are different but when I search the internet for VT characters, I find both are linked with each other, here is the link http://www.theasciicode.com.ar/ascii-control-characters/vertical-tab-male-symbol-mars-ascii-code-11.html

I guess same is the other control characters as well. Is it that the control characters have their symbolical equivalents?

Can someone please explain what relation exists between the two?


Solution

  • That website is just showing ASCII codes and ALT codes side by side, since most of the characters are the same, except for control characters. They are in different character sets, but have the same decimal value in their respective tables. Java uses Unicode, where ♂ is \u2642 and VT is \u000B.

    Here's a chart, where a blank means it doesn't exist in that character table:

    Char | ASCII | ALT | Unicode
    -----|-------|-----|--------
     ♂   |       | 11  | 0x2642
     VT  |  11   | 011 | 0x000B