How to translate 1 char
to byte[]
? Do not offer translations to String
- onechar c = 1; byte [] b = {(byte) c}; - Russtam
- And I think so: char c = 'c'; byte [] b = new byte [2]; b [0] = (byte) c; b [1] = (byte) (c << 4); - Vladislav Pyatkov
- one@VladislavPyatkov why are you moving 4 bits left? if he wants to get from char 2 bytes, then char cc = 257; byte [] b = {(byte) (cc >> 8), (byte) cc}; - Russtam
- @Russtam Yeah, I got it wrong. But the essence is clear: char 2 bytes, i.e. when we cast byte, we multiply the mask 0x00FF. I hurried .. - Vladislav Pyatkov
|