Java Byte Array Create toBytesFromUnicode(String s)

Here you can find the source of toBytesFromUnicode(String s)

Description

to Bytes From Unicode

License

Open Source License

Declaration

public static byte[] toBytesFromUnicode(String s) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

public class Main {
    public static byte[] toBytesFromUnicode(String s) {
        int limit = s.length() * 2;
        byte[] result = new byte[limit];
        char c;//from   ww w . j ava  2  s .  co m
        for (int i = 0; i < limit; i++) {
            c = s.charAt(i >>> 1);
            result[i] = (byte) (((i & 1) == 0) ? c >>> 8 : c);
        }
        return result;
    }
}

Related

  1. toBytesFromBin(String binSymbols)
  2. toBytesFromHexStr(String hexStr)
  3. toBytesFromHexString(String digits)
  4. toBytesFromOct(String octSymbols)
  5. toBytesFromString(String s)
  6. toBytesHexEscaped(final byte[] s, final int off, final int len)
  7. toBytesInt32BE(int w)
  8. toBytesLittleEndian(long value, int cnt)
  9. toBytesOctalEscaped(final byte[] s, final int off, final int len)