Android XML String Unescape unescape(String input)

Here you can find the source of unescape(String input)

Description

Useful to replace the escaped characters their unescaped counterparts Ex: & -> &

License

Open Source License

Parameter

Parameter Description
input the string to unescape

Return

the unescaped string

Declaration

public static String unescape(String input) 

Method Source Code

//package com.java2s;
/*//from   w w  w . j  a v a 2s .c  om
 * Tomdroid
 * Tomboy on Android
 * http://www.launchpad.net/tomdroid
 * 
 * Copyright 2009, Benoit Garret <benoit.garret_launchpad@gadz.org>
 * 
 * This file is part of Tomdroid.
 * 
 * Tomdroid is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Tomdroid is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Tomdroid.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Useful to replace the escaped characters their unescaped counterparts
     * Ex: &amp;amp; -> &amp;
     * 
     * @param input the string to unescape
     * @return the unescaped string
     */
    public static String unescape(String input) {
        return input.replace("&amp;", "&").replace("&lt;", "<")
                .replace("&gt;", ">").replace("&quot;", "\"")
                .replace("&apos;", "\'");
    }
}

Related

  1. xmlUnescape(String xml)
  2. unescape(String source)
  3. unescapeXML(final String xml)
  4. urlEscape(String s)
  5. replaceEscape(String result)