Skip to Content

Issue with special characters while using Base64 encoding

Dec 22, 2017 at 05:21 PM


avatar image

Hello Experts,

I am using Base64 encoding to encode the xml message and send it to a single field. The encoding is unable to handle the special characters(ex. characters of Spanish language). The message gets encoded but the special character is converted to some junk value.

Is there any way to handle this? Below is the UDF code being used:

BASE64Encoder encoder = new BASE64Encoder();

String encoded = encoder.encode(payload.getBytes());

encoded = encoded.replace("\n","").replace("\r", "");

return encoded;

Kindly advice changes in code if required.

Thanks in advance!


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Manoj K Dec 23, 2017 at 12:27 PM

Try with mentioning the encoding in the getBytes method:

Ex: encoder.encode(payload.getBytes("UTF-8"));

And also instead if using SUN's Base64 class use the default SAP provide a class to encode.

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

Hi Manoj,

Received below error when above code used:

error: unreported exception UnsupportedEncodingException; must be caught or declared to be thrown
String encoded = encoder.encode(payload.getBytes("UTF-8"));