Java Unicode Create toUnicode(String strText)

Here you can find the source of toUnicode(String strText)

Description

to Unicode

License

Open Source License

Declaration

public static String toUnicode(String strText) throws UnsupportedEncodingException 

Method Source Code

//package com.java2s;
/**//  w  w  w . j  a v  a 2 s.  co  m
 * Copyright (C) 2002-2005 WUZEWEN. All rights reserved.
 * WUZEWEN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.io.UnsupportedEncodingException;

public class Main {

    public static String toUnicode(String strText) throws UnsupportedEncodingException {
        char c;
        String strRet = "";
        int intAsc;
        String strHex;

        for (int i = 0; i < strText.length(); i++) {
            c = strText.charAt(i);
            intAsc = (int) c;
            // System.out.println(i+ "  intAsc ss="+intAsc);
            if (intAsc > 128) {
                strHex = Integer.toHexString(intAsc);
                strRet = strRet + "\\u" + strHex.toUpperCase(); //&#x
            } else {
                strHex = Integer.toHexString(intAsc);
                strRet = strRet + "\\u00" + strHex.toUpperCase(); //&#x
            }
        }
        return strRet;
    }
}

Related

  1. toUnicode(String str)
  2. toUnicode(String str)
  3. toUnicode(String str)
  4. toUnicode(String str)
  5. toUnicode(String string)
  6. toUnicode(String text)
  7. toUnicode(String text)
  8. toUnicode(String theString, boolean escapeSpace)
  9. toUnicode(String value)