Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Unicode  RSS feed

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
______________________________________________________________
char A = '\u0005';
char B = 5;
if (A==B)
System.out.println("Equal ");
else
System.out.println("Not equal");

A = '\u0025';
B = 25;
if (A==B)
System.out.println("Equal ");
else
System.out.println("Not equal");
Output
------
Equal
Not equal
______________________________________________________________
Could someone explain me this code?
Thanks,
Malar.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do a little change in ur code and see it yourself.
char A = '\u0005';
char B = 5;
if (A==B)
System.out.println("Equal "+ A +" " +B);
else
System.out.println("Not equal");
A = '\u0025';
B = 25;
if (A==B)
System.out.println("Equal ");
else
System.out.println("Not equal"+ A +" " +B);

Hope it explains.
Jennifer.
 
Malar Ravi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jennifer,
Thanks for your response. The point which I missed to understand before posting the previous code is that Unicode character is represented by \u followed by 4 hexadecimal digits.
A = '\u0025'
B = 25;
If I replace B=25 with B = 37; (equivalent of 0x0025) then I get "Equal" as output in my previous code.
- Malar.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a new one,I don't know how the char convert to Unicode ,
Is your question means that [char 'u00xx']not always equals to [char xx]what is the relations?
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
While watching:
char a = '\uxyzw';
every letter will be a HEXA value (0..F)
char b = n;
n it's in decimal.
So if (xyzw)base16 it is equal to (n)base10 so will be the characters.
..Cristian
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guoyuan,
Each Unicode character maps to a specific character based on a given character set or character encoding.
For example, in the standard character set '\u0025' maps to '%', '\u0037' maps to '7', '\u0061' maps to 'a'.
To find out more about how it works see www.unicode.org. For a quicker overview check out this Unicode FAQ and try the the Unicode decoder
Hope that helps.
[This message has been edited by Jane Griscti (edited November 07, 2001).]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!