Java Unicode Create toUnicodeBytes(String str)

Here you can find the source of toUnicodeBytes(String str)

Description

to Unicode Bytes

License

Open Source License

Declaration

private static byte[] toUnicodeBytes(String str) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;

public class Main {
    private static byte[] toUnicodeBytes(String str) {
        byte[] unicodeBytes = null;
        try {// www. j a va 2s. c om
            byte[] unicodeBytesWithQuotes = str.getBytes("Unicode");
            unicodeBytes = new byte[unicodeBytesWithQuotes.length - 2];
            System.arraycopy(unicodeBytesWithQuotes, 2, unicodeBytes, 0, unicodeBytesWithQuotes.length - 2);
        } catch (UnsupportedEncodingException e) {
            // This should never happen.
            e.printStackTrace();
        }
        return unicodeBytes;
    }
}

Related

  1. toUnicode(String text)
  2. toUnicode(String text)
  3. toUnicode(String theString, boolean escapeSpace)
  4. toUnicode(String value)
  5. toUnicode(StringBuilder strBuilder, char ch)
  6. toUnicodeEncoded(String data)
  7. toUnicodeEscape(char c)
  8. toUnicodeEscape(int ch)
  9. toUnicodeLiteral(String s)