Skip to Content

Decode UDF not working Properly.

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 11, 2017 at 09:19 PM

    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")
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06, 2017 at 03:11 PM

    Hi Karthik,

    What do you want to decode? a base64 string?

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 06, 2017 at 11:56 PM

    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")

    Add comment
    10|10000 characters needed 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)