Java Unicode Create toUnicode(String value)

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

Description

to Unicode

License

Open Source License

Declaration

public static String toUnicode(String value) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright ? 2001, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * /*from  ww w  . j a  v a  2  s .c  o m*/
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

public class Main {
    public static String toUnicode(String value) {
        if (value == null) {
            return value;
        }

        String result = ""; //$NON-NLS-1$
        for (int i = 0; i < value.length(); i++) {
            char character = value.charAt(i);
            if (character == '>') {
                result += "&gt;"; //$NON-NLS-1$
            } else if (character == '<') {
                result += "&lt;"; //$NON-NLS-1$
            } else {
                result += character;
            }
        }
        //System.out.println(value + " " + result);
        return result;
    }
}

Related

  1. toUnicode(String string)
  2. toUnicode(String strText)
  3. toUnicode(String text)
  4. toUnicode(String text)
  5. toUnicode(String theString, boolean escapeSpace)
  6. toUnicode(StringBuilder strBuilder, char ch)
  7. toUnicodeBytes(String str)
  8. toUnicodeEncoded(String data)
  9. toUnicodeEscape(char c)