0

When we encode the string including the 'é' special character, it displays this error in the log.

login:jag Cannot convert org.mozilla.javascript.NativeArray@6da663da to byte[]

The error is caused when running the

var encodedString = Base64Utils.encode(byteArray)

line.

var Base64Utils = Packages.org.apache.axiom.util.base64.Base64Utils;
var username = 'testuser';
var password = '431éa23';
var inputString = username + ":" + password;
new Log("stringmsg").info(inputString);
var byteArray = [];

for (var i = 0; i < inputString.length; ++i) {
    new Log("iterate").info(inputString.charCodeAt(i));
    byteArray.push(inputString.charCodeAt(i));
}
new Log("stringarray").info(byteArray);
var encodedString = Base64Utils.encode(byteArray);

This is the code that I have run. I have tried with other special characters. They are working fine with other special characters. The issue is caused by this special character only. I have tried several methods, but those won't work out. What should I do to encode the string with this special character?

Sahan Randika
  • 47
  • 1
  • 14

0 Answers0