cancel
Showing results for 
Search instead for 
Did you mean: 

HTML Entity Escape Character Conversion

Former Member
0 Kudos

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

http://www.theukwebdesigncompany.com/articles/article.php?article=11

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

many Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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 == '"')
					sb.append("&quot;");
				else if (c == '&')
					sb.append("&amp;");
				else if (c == '<')
					sb.append("&lt;");
				else if (c == '>')
					sb.append("&gt;");
				else if (c == '
')
					// Handle Newline
					sb.append("&lt;br/&gt;");
				else {
					int ci = 0xffff & c;
					if (ci < 160)

						sb.append(c);
					else {

						sb.append("&#");
						sb.append(new Integer(ci).toString());
						sb.append(';');
					}
				}
			}
		}
		return sb.toString();
	}

rewrd points if it help u

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi All,

Thanks for suggetions..,

Former Member
0 Kudos

Hi Veeranjaneyulu.P ,

there are certain special characters that are not supported by UTF 8 encoding . For ex: foreign language characters

for this you can follow this link

http://www.dpawson.co.uk/xsl/characters.html

so i suggest you to use ISO encoding in place of UTF 8 encoding

In your receiver communication channel under text XML payload manipulation there is a field XML code , there you can define the coding you want fro example UTF 8 or ISO encoding

here if you will give ISO encoding in this field of receiver channel. then your output file may contain special characters such as foreign characters also

Hope this may solve your problem

Thanks

sandeep

PS : if helpful kindly reward points

former_member192343
Active Contributor
0 Kudos

what about this:


String win1251String = "STRING IN_WINDOWS-1251";
String utf8String= new String(win1251String.getBytes(“windows-1251”),”utf-8”);

stefan_grube
Active Contributor
0 Kudos

There is no support for this in PI.

I think the best way is writing a Java Mapping.

Stefan

former_member192343
Active Contributor
0 Kudos

i suppose there are special converting java functions where you can convert entire string to utf-8 and from utf-8.