DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

How to parse special symbol ± in gateway script

  • 1.  How to parse special symbol ± in gateway script

    Posted Sun September 03, 2023 11:53 PM

    Hi All,

    I am trying to convert a non-XML input to XML using gateway script.

    There is one special scenario I have encountered. The input data had a special symbol ± in the data.

    When outputted by gateway script, the value of this symbol got converted to � by DataPower.

    Is there any way to preserve the symbol on the output?

    Any help is much appreciated.

    Thanks,

    Geoff



    ------------------------------
    Geoff Xu
    ------------------------------


  • 2.  RE: How to parse special symbol ± in gateway script

    Posted Mon September 04, 2023 08:30 PM

    Hi All,

    I found the root cause and fix for this in case anyone encountered the same issue.

    So the root cause is the conversion from buffer to String. Default is UTF-8.

    I need to change that to latin1, which is ISO-8859-1 encoding. Then the symbol ± is displayed correctly.

    The code snippet looks like this:

    let str = buffer.toString('latin1');



    ------------------------------
    Geoff Xu
    ------------------------------