cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to convert Arabic into Hex

Former Member
0 Kudos

Hi,

I have to convert an incoming Arabic string (Arabic letters) into the hex values in my message magging.

Can anybody help me with that UDF?

Thanks in advance

Dominic

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Dominic,

Do you want to parse all received arabic chars received in your payload to their corresponding byte value and storing them in a byte array or something similar ?

Do you want to do this in a graphical msg mapping with a UDF function ?

For UDF function, you will have to parse the corresponding input node (plugged in a a java string ?) to a byte sequence serialized in an output node (string), ie :

"blabla" -> "626C61626C61"

If you still need to find a solution, let me know, I may have something similar (I do not have access to my sources at the moment), for I had to do this once

Rgds

Chris

stefan_grube
Active Contributor
0 Kudos

When you want to convert an arabic text string into hex, how should the hex string look like? How should the hex values be determined?

Regards

Stefan

GabrielSagaya
Active Contributor
0 Kudos

Hi,

Your encoding standard in your message mapping is UTF-8 by default.

Hence you have to change to ISO-8859-5 encoding format which supports your Arabic characters.

Hence you should perform either XSLT mapping or Java mapping for conversion.

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="ISO-8859-1"/>

<xsl:template match="/">

<xsl:copy-of select="*" />

</xsl:template>

</xsl:stylesheet>

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79...

Former Member
0 Kudos

Hi Gabriel,

thanks for you response.

My scenario is the following:

I'm getting a message via a Z-RFC from ERP system. Only one field is filled with Arabic letters. As we are adviced to use message mapping, I have to convert the arabic valu of that field to a hex value because it's a requirement by the receiver.

So my only possibility is to write an UDF wich converts the value.

For that I need support in the Java development for the UDF.

Thanks in advance

Dominic

GabrielSagaya
Active Contributor
0 Kudos

if you want to replace all & to &amp;.

Here is a sample code:

code public void execute (InputStream in, OutputStream out)

throws StreamTransformationException {

try {

int c;

while ((c = in.read()) != -1) {

if (c != '&') {

out.write(c);

} else {

// ampersand

out.write("&amp;".getBytes());

}

} // while

out.flush();

} catch (Exception e) {

throw new StreamTransformationException(e.getMessage(),e);

}

}

Like wise you can change your arabic char set into corresponding UTF-8 char set.

Former Member
0 Kudos

Hi Gabriel,

I don't want to replace all & to &....I just want to transform/convert an arabic string into hexadecimal values.

Like wise you can change your arabic char set into corresponding UTF-8 char set.

Can you explain me a little more what you mean with that?

Thanks & Regards

Dominic

GabrielSagaya
Active Contributor
0 Kudos

Hi

out.write("&".getBytes());

for eg

if you want to print Proctor & gamble in target, it wont print due to escape sequence '&'.

for that you are going to convert & into 'and' in target structure by java mapping.

likewise

what are all the arabian char you receive try to convert into your native understandable one format.

Former Member
0 Kudos

Hi Gabriel,

do you mean I should replace every single arabic character with another character?

If so, 1st I don't speak arabic and 2nd this would be an enourmous effort.

I think there is a much easier way with some java functions...

Dominic