Saturday, April 12, 2014

Newbie question: char to byte [2] how to do? ?


RT
Assuming:
byte [] bytes = new byte [2];
char c;

accounting for two-byte char, byte only one byte,
that my question is:
How to do so bytes [0] is the low value of c; bytes [1] is a high value of c? ? ?


Java pointer seemingly did it, I do not know how to do ... seeking advice ~ ~ thanks! !




<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:


First, you do not have java how relations bytes stored (not as tangled as c, which is the java features; course, you want to get to the bottom, then put it entered into the console at a glance).

Actual how operations can refer http://blog.csdn.net/chenzhanhai/article/details/6367842
Reply:
cited a floor jsjxieyang reply:


First, you do not have java how relations bytes stored (not as tangled as c, which is the java features; course, you want to get to the bottom, then put it entered into the console at a glance).

Actual how operations can refer http://blog.csdn.net/chenzhanhai/article/details/6367842

You did not answer my question, look at the blue words
Reply:
reference to the second floor CCDDzclxy reply:
you did not answer my question, look at the blue word

You try the case character 'a' turn into bytes, you'll find it only turned into a byte after byte of. There are the characters 'You' (utf-8 encoding) turn into bytes, you'll find it turn into byte representing three bytes. ---- This process of transformation you simply can not control.

Description: java stored character is one that is two bytes, but who do not care what it is stored in memory and the high, low deposit what these things are done by the virtual machine. You do not really turn over the bar from c

Conclusion: I can not help you.
Recommendation: Available research char conversion byte source

No comments:

Post a Comment