This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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).]
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!