| Author |
does 1 char equal to 2 bytes?
|
yang tao
Greenhorn
Joined: Sep 25, 2008
Posts: 16
|
|
1 char equal to 2 bytes please send me a reference thank you
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24041
|
|
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.
|
[Jess in Action][AskingGoodQuestions]
|
 |
yang tao
Greenhorn
Joined: Sep 25, 2008
Posts: 16
|
|
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
Joined: Jul 08, 2003
Posts: 24041
|
|
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
Joined: Sep 25, 2008
Posts: 16
|
|
|
i do not have any example here, but tx for you help, i will do more research by myself
|
 |
 |
|
|
subject: does 1 char equal to 2 bytes?
|
|
|