• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jxam #

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Jxam says that following is true:
"UTF uses as many bits as are needed to represent a character."
But my understanding is UTF use maxium 3 byte.
please help me,
tom gong
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from JLS:
Java's UTF representation of the string is this:
Every character in the string is represented by one, two or three bytes and the rule it follows to do it is this:
(a) If the character is in the range '\u0000' through '\u007f', then it is represented by one byte
(b) If the character is in the range '\u0080' through '\u07ff', then it is represented by two bytes
(c) If the character is in the range '\u0800' through '\uffff', then it is represented by three bytes.
So, how many bytes are used to represent a character depends on what the value of character is.
HTH
 
tom gong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Viji Bharat:
upon your message, UTF never use more than three byte to represent a char, it it true?
sorry about this confusion,thanks for help!
tom gong
 
tom gong
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it,
1, UTF uses as many bits as are needed to represent a character
2, 3 byte is big enough to represent all international characters by UTF
there is no contradictious between 1 and 2.
sorry about that,
tom gong
 
reply
    Bookmark Topic Watch Topic
  • New Topic