This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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).]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!