Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HTML Entity Escape Character Conversion

Requirement is to Convert UTF-8 encoded Speciual language characters to HTML Entity Escape Character's. For example In the source I have a Description field with value "Caractéristiques" which is 'Characteristics' in French, This needs to be converted to "Caractéristiques" when sent to the Reciever.i.e the Special Language Symbols like é = é (in HTML Entity format.)

Below is the Link for a List of HTML Entity Char's

could anybody please suggest how this can be achieved in mapping...any UDF or Encoding techniques...?

many Thanks.

Former Member
Former Member replied

Hi Veera

this is ajay

code for ur problem

String ToHTMLEntity(String s) {
		StringBuffer sb = new StringBuffer(s.length());

		boolean lastWasBlankChar = false;
		int len = s.length();
		char c;

		for (int i = 0; i < len; i++) {
			c = s.charAt(i);
			if (c == ' ') {
				if (lastWasBlankChar) {
					lastWasBlankChar = false;
					sb.append(" ");
				} else {
					lastWasBlankChar = true;
					sb.append(' ');
			} else {
				lastWasBlankChar = false;
				// HTML Special Chars
				if (c == '"')
				else if (c == '&')
				else if (c == '<')
				else if (c == '>')
				else if (c == '
					// Handle Newline
				else {
					int ci = 0xffff & c;
					if (ci < 160)

					else {

						sb.append(new Integer(ci).toString());
		return sb.toString();

rewrd points if it help u

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question