Skip to Content
0

Decode UDF not working Properly.

Mar 06, 2017 at 01:44 PM

132

avatar image

Dear Experts,


I have used Apache Common Codec file and trying to Decode but its not decoding properly decode-1.png.

However when i decode the data in UTF-8 format in Online tool and then encode it in UTF-8 Format in Online Tool, then it is converting Properly in Mapping decode-2.png ,


So i am assuming it is problem with UTF format and i am trying to convert it in UTF-8 format using Apache StringUtils Class utf8.png but i am getting error with Method utf8-1.png. I am not sure about Java, Please let me know how can i convert to UTF8 format..

.

decode-1.png (8.2 kB)
decode-2.png (13.1 kB)
utf8.png (10.3 kB)
utf8-1.png (17.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Stefan Grube Mar 11, 2017 at 09:19 PM
0

Instead of using Apache Common Codec, you can use standard Java class

javax.xml.bind.DatatypeConverter

Import this class to your mapping, then you can use it in your UDF;

byte[] bytes = DatatypeConverter.parseHexBinary(hexString);
String decodedString = new String (bytes,"UTF-16")
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Stefan,

Thank you. I am able to decode now.

0
Iñaki Vila Mar 06, 2017 at 03:11 PM
0

Hi Karthik,

What do you want to decode? a base64 string?

Regards.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Inaki,

Thank you for the response. Yes it is base64 string. But if i use UTF-8 format Encoded string from Online Tool https://www.base64encode.org/ then the Decoder UDF is working fine as in the attached screenshot decode-2.png. Please let me know how to decode it..

Thanks and Regards,

Karthik

0
Stefan Grube Mar 06, 2017 at 11:56 PM
0

It seems that you have an encoded UTF-16 file. Is this what you expect?

when you are sure to expect UTF-16, you can do:

decodedString = new String (Base64.decodeBase64(myBase64String),"UTF-16")

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Stefan,

Thank you for the response. Please let me know if this UDF is proper as i am not sure how to write UDF. utf8.png

I am getting error as unable to find method decodeBase64. Please let me know if i have to import any class. utf8-error.png The team sending data is not encoding in any format. Team is sending data in XSTRING. Please let me know how to decode this..

Thanks and Regards,

Karthik

utf8.png (11.8 kB)
utf8-error.png (18.1 kB)
0