public static String unescapeHTML4(String str)
	{
		if (str == null)
			return null;
		int index = 0;
		Integer cCode;
		while ((index = str.indexOf('&', index)) != -1)
		{
			int index2 = str.indexOf(';', index + 1);
			if (index2 == -1)
				return str;
			if (str.charAt(index + 1) == '#')
			{
				int result = 0;
				try {
					if (str.charAt(index + 2) == 'x')
					{
						for (int i = index + 3; i < index2; ++i)
							result = (result << 4) | hexValue(str.charAt(i));
					} else {
						result = Integer.parseInt(str.substring(index + 2, index2));
					}
				} catch (NumberFormatException e) {
					index = index2;
					continue;
				}
				str = str.substring(0, index) + Character.toString((char) result) + str.substring(index2 + 1);
				++index;
			} else if ((cCode = knownEscapes.get(str.substring(index + 1, index2))) != null)
			{
				str = str.substring(0, index) + Character.toString((char) ((int) cCode)) + str.substring(index2 + 1);
				++index;
			} else {
				index = index2 + 1;
			}
		}
		return str;
	}