public static String encodeData(String data) {
		StringBuilder buffer = new StringBuilder();
		int length = data.length();

		for (int i = 0; i < length; i++) {
			char ch = data.charAt(i);

			if (ch == '<') {
				buffer.append(LESS_THAN_ENTITY);
			} else if (ch == '>') {
				buffer.append(GREATER_THAN_ENTITY);
			} else if (ch == '&') {
				buffer.append(AMPERSAND_ENTITY);
			} else if (ch >= ' ' && ch <= '~') {
				buffer.append(ch);
			} else {
				buffer.append(ENTITY_CODE_PREFIX);
				buffer.append((int) ch);
				buffer.append(';');
			}
		}
		return buffer.toString();
	}