Java Unicode unicode2Byte(String s)

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

Description

unicode Byte

License

Apache License

Declaration

public static byte[] unicode2Byte(String s) 

Method Source Code

//package com.java2s;
/*//from   w  w w .j ava 2s. com
 * BJAF - Beetle J2EE Application Framework
 * ???J2EE???????????
 * ??????2003-2015 ??? (www.beetlesoft.net)
 * 
 * ??????????????????
 *<http://www.apache.org/licenses/LICENSE-2.0>
 *????????????????????????
 *
 * ???????????????????????????????
 * ??? <yuhaodong@gmail.com/>.
 */

public class Main {
    public static byte[] unicode2Byte(String s) {
        int len = s.length();
        byte abyte[] = new byte[len << 1];
        int j = 0;
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            abyte[j++] = (byte) (c & 0xff);
            abyte[j++] = (byte) (c >> 8);
        }

        return abyte;
    }
}

Related

  1. unicode(String ipStr)
  2. unicode(String s)
  3. unicode(StringBuilder buf, char c)
  4. Unicode2ASCII(String unicode)
  5. Unicode2GBK(String dataStr)
  6. unicode2native(String s)
  7. unicodeChar(char a, char b, char c, char d)
  8. unicodeCodepointToString(char cp, boolean shortenIfPossible, String prefix, boolean upperCase)