Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create char using unicode value

 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I know this should be super basic, but I've Googled it and found this helpful webpage that provided a workaround--I just copy the char and paste it into my code. However, it would still be nice to know how to construct the following character knowing that the unicode value is 253:

I appreciate your help,
Stephen
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char funnyY = '\U0253';
But, you need a Unicode-savvy viewer to see the actual character.
Regards,
Jeff
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remeber, the Unicode values for \u are Hex Based. This would actually be
'\u00DD'
Also, since char is a number primative you can set it with number.
char crazyY = 253;
Since you set it with a literal, no cast is required.
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assumed, because the value was called "Unicode value 253", that 253 was hex. I probably should have confirmed the value against the Unicode character set, eh?
Regards,
Jeff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic