This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

does 1 char equal to 2 bytes?  RSS feed

 
yang tao
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 char equal to 2 bytes
please send me a reference

thank you
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Java 'char' is 16 bits, or two bytes, in length, so yes.

BUT

Does a single 'char' translate to two bytes when written to a file? That depends entirely on the encoding in use. If the encoding is iso-latin or UTF-8 (which are very common here in the US) then all the alphanumeric characters used in English will be written to a file as a single byte per character.
 
yang tao
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i am using the java to write the string and then update the information to the orcl/mysql database

so in this condition, does 1 char is 2 bytes?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on exactly what you're doing, and what encoding you're using, or what the default encoding is, which will vary by location.

If you can show us more concretely what you're doing, and where you're getting an unexpected result, maybe we can help you.
 
yang tao
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i do not have any example here, but tx for you help, i will do more research by myself
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!