• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How can i print symbol from unicode number

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used the website https://symbl.cc/en/27A7/ to find symbols and unicode codes but I don't know how to print them. Can anyone help me here? Thanks

Unicode Name Squat Black Rightwards Arrow
Unicode Number U+27A7
HTML Code ➧
CSS Code \27A7
Unicode Block Dingbats
Unicode Subblock Dingbat arrows
Unicode Version 1.1 (1993)
 
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java, you can embed any Unicode character anywhere in your code by prefixing the hexadecimal codepoint number with the sequence \u .

Here's an example:

Before compilation, the Java preprocessor will convert it to the following code:

Obviously, it's bad to write code like this, but it's a good example of how the preprocessor works.
 
Marshal
Posts: 79971
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:. . . Before compilation . . . .

Will that code compile without letters in the identifier name?Another way to do it is to use the %c tag:-You can add the char as a code point to a StringBuilder:- Or simply print the char:-
 
Saloon Keeper
Posts: 28321
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing to note, though. The question was "How can I print?".

You can encode any Unicode character using techniques described above. Java Strings are always Unicode. But to print them you need 2 additional requirements met:

1. The output channel (Stream encoding or GUI display) has to be capable of non-translated Unicode output. Or, if you're outputting EBCDIC or something like that, for example, that's still OK, but only providing that the translation provided can also accurately translate the Unicode character of interest.

2. The output media used for "printing" (including GUI or terminal display) is using a font that defines a glyph for that character. If I want to output a Unicode point that defines an ancient Sumerian character, then my font has to have a graphic (glyph) defined that renders that character. Otherwise a default (such as a hollow box character) gets displayed.
 
Kieu Thoai
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the answers
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're on Windows 10 then using a different terminal window than the standard CMD terminal is very important. In the Java GUI you're generally golden as long as the font supports the glyph (as indicated before). Windows 11 introduced the new Windows terminal which is much more capable than the previous one (it would have been hard to create a less capable one to be honest). You can also get or enable it for Windows 10. On Linux and macOS most terminals default to UTF-8 so no problems expected there.
 
I'm full of tinier men! And a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic