Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Is there any javascript option to make encoded-string as UTF-8 in WSO2 Script mediator?

I'm trying to convert incoming encoded(RSA) string values to UTF-8 in the WSO2 EI 6.6.0 Script Mediator mediator.

Incoming Request:

{
    "result": {
        "message": ".eJwdy00OwiAQBtC7zFqS4Ufg8zLNUIaGDZjaxoXx7ja-_fvQc751X3qlB2Wp4kKCU47BZy4A7pa9uuitqNKN5t63PuToY1vO87-wri02gSlSiwloMKhcDZxoSClDAl-zj9exjHkFy0zfH5pUI3w.YfvMdQ.GcmMQuY3BN33JATAfFB3ZyeXO8U"
    }
}

By using script mediator trying to convert above message content into utf-8.

Code:

<property expression="json-eval($.result.message)" name="input" scope="default" type="STRING"/>
<script language="js"><![CDATA[var id = parseInt(mc.getProperty("input"));
                var encoded_id  = utf8.encode(id); 
                mc.setProperty("encoded_id", encoded_id );]]></script>
            <log level="custom">
                <property expression="get-property('encoded_id')" name="encoded_id"/>
            </log>

Facing below error:

[2022-02-07 13:05:32,279] ERROR {ScriptMediator} - {api:utf8enc} The script engine returned an error executing the inlined js script function mediate com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "utf8" is not defined. (<Unknown Source>#2) in <Unknown Source> at line number 2

May I know the way to convert the encoded value to UTF-8 by using javascript functionality?

Note: expecting to shorten the above lengthy value(substring shouldn't be used here) after convert it into utf-8?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!