cancel
Showing results for 
Search instead for 
Did you mean: 

Special character in message

former_member296836
Participant
0 Kudos

Dear all,

we received messages with value & # x 2 ; (without blanks) as content in one field.

I tried to replace it in mapping, but I am not able to load this message in mapping editor

as test message.

Is there a possibility to replace this characters e.g. with java mapping as first mapping to

replace it? Or is there no change to replace such special characters?

regards

chris

Edited by: Christian Riekenberg on Jun 29, 2011 6:25 PM

Accepted Solutions (1)

Accepted Solutions (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Chris,

You should be able to copy paste these characters in test tab of message mapping since these are all printable characters. You can replace all of them in java mapping, if you are using one for your work. Here is a very simple UDF that you need to put across the fields in messages which you think can carry such characters.


public static String removeSpecialChar(String s)
	{
		
		try
		{
			int i,j;
			String a="";
			String stringSet[]={"& # x 2;","&#y3;","&#r2;"};
			for(i=0;i<stringSet.length;++i)
			{
				j=s.indexOf(stringSet<i>);
				while(j>=0)
				{
					a=s.substring(0,j);
					a+=s.substring(stringSet<i>.length()+j);
					s=a;
					j=s.indexOf(stringSet<i>);
				}
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return s;
	}

The input and output for this UDF is shown below


input=abcdef& # x 2;ghijk&#y3;lmno&#r2;pqrst&#x2;uvwx&#r2;yz&#x2;
output=abcdefghijklmnopqrstuvwxyz

You can see from here that there is a set of special character string I have used in UDF. Please remove the blanks between characters & # x 2 wherever you see them, since that causes printing errors in posts, so i had to include them.

String stringSet[]={"& # x 2;","&#y3;","&#r2;"};

you can reduce or increase this list as per your requirement to include all the special character set.

Hope this helps.

regards

Anupam

Answers (2)

Answers (2)

stefan_grube
Active Contributor
0 Kudos

Where do you get the messages from?

You should rather figure out, if you can remove the hex 02 value in sender application.

When you just remove the hex 02, then your message might be corrupt.

For example: your sending system has packed numbers, which are not translated to XML numbers.

former_member296836
Participant
0 Kudos

Thanks all for your reply.

The value in source DB was null and PI has read it as & #x2

As solution I ask the source system admin to insert ToReplace

as default value for this field. In mapping I can simply replace it.

Points given. Thanks

Regards

Chris

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>Is there a possibility to replace this characters e.g. with java mapping as first mapping to

replace it? Or is there no change to replace such special characters?

Yes, it is possible to replace characters using java mapping as first mapping in the operation mapping.

Just curious Why dont filter out or resolve issues at the sender side itself.