Here you can find the source of unescape(String line, int start, int end)
private static String unescape(String line, int start, int end)
//package com.java2s; /***************************************************************************** * This file is part of the Prolog Development Tool (PDT) * /* w w w .j a va 2 s. co m*/ * Author: Lukas Degener (among others) * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start * Mail: pdt@lists.iai.uni-bonn.de * Copyright (C): 2004-2012, CS Dept. III, University of Bonn * * All rights reserved. This program is 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 * ****************************************************************************/ public class Main { private static String unescape(String line, int start, int end) { StringBuffer sb = new StringBuffer(); boolean escape = false; StringBuffer escBuf = new StringBuffer(); for (int i = start; i < end; i++) { char c = line.charAt(i); switch (c) { case '&': escape = true; break; case ';': if (escape) { escape = false; String escSeq = escBuf.toString(); escBuf.setLength(0); if ("lt".equals(escSeq)) { sb.append('<'); } else if ("gt".equals(escSeq)) { sb.append('>'); } else if ("cbo".equals(escSeq)) { sb.append('{'); } else if ("cbc".equals(escSeq)) { sb.append('}'); } else if ("amp".equals(escSeq)) { sb.append('&'); } else if ("apos".equals(escSeq)) { sb.append('\''); } else if ("quot".equals(escSeq)) { sb.append('\"'); } } else { sb.append(c); } break; default: if (escape) { escBuf.append(c); } else { sb.append(c); } break; } } return sb.toString(); } }