File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does 1 char equal to 2 bytes?

 
yang tao
Greenhorn
Posts: 16
  • 0
  • 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
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • 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
  • 0
  • 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
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic