Your code only removes Unicode characters not on BMP (Basic Multilingual Plane, the first 65536 characters).
U+2747 (❇) is in BMP and therefore not removed by your code.
You need to walk through all BMP characters and identify those that you want to exclude.
That is needed because there is no function "isEmoji()".
After you have identified the characters to remove, you need to enhance your code to remove them as well.
Here you can quickly access the complete BMP in your browser in 8 parts:
Original Message:
Sent: Mon April 14, 2025 12:29 PM
From: D@viiid
Subject: Remove emoji from input request
Hello Hermann
Just a precision about the script you helped me to develop
Why some smileys are not replace
Example :
<ObjetMail>Re: Fwd: SG17-DSIN-2010-00230 test emoji dans l'objet🤨 🧠💑🐄🍀🐊🐝🐴🚨⛵🍜㊙️🅰️🈳❇️♻️💭🕕🕛🕜</ObjetMail>
has been replace by
<ObjetMail>Re: Fwd: SG17-DSIN-2010-00230 test emoji dans l'objet ⛵㊙️️❇️♻️</ObjetMail>
It seems that some emojis are included in BMP.
❇️ --> U+2747 (sparkle) + U+FE0F (variation selector) :both are included in BMP
Could you help me ? :)
------------------------------
D@viiid
Original Message:
Sent: Fri April 11, 2025 06:40 AM
From: Hermann Stamm-Wilbrandt
Subject: Remove emoji from input request
Hi Daviid,
your script works indeed:
$ echo -e "foo\xF0\x9F\x91\x8Dbar"foo👍bar$ coproc2 onlyBmp.js <(echo -e "foo\xF0\x9F\x91\x8Dbar") http://127.0.0.1:2227 foobar$
The problem is that your script is a Non-XML script, and INPUT seems to be available as is in MPGW, but not in WSP. You should use a GatewayScript with readAsXML() and only replace emojis for CorpsMail element.
------------------------------
Hermann Stamm-Wilbrandt
Compiler Level 3 support, IBM DataPower Gateways
IBM
Boeblingen
Original Message:
Sent: Fri April 11, 2025 05:44 AM
From: D@viiid
Subject: Remove emoji from input request
Hermann,
I used this gatewayscript below
session.input.readAsBuffer(function (readAsBufferError, data) { if (readAsBufferError) { console.error('Error on readAsBuffer: ' + readAsBufferError); } else { var content = data.toString(); var cleaned = content.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, ''); session.output.write(cleaned); } });
I don't understand why it works in a MPG with 'soap' as request type, but it doesn't work in a WSP..
Do you have an idea ?
------------------------------
D@viiid
Original Message:
Sent: Fri April 11, 2025 02:46 AM
From: Hermann Stamm-Wilbrandt
Subject: Remove emoji from input request
Hi,
here is the easy part.
First have a xform action with a stylesheet or a GatewayScript action with input contect INPUT and output context _INPUT_
The change all actions with INPUT as input context to use _INPUT_ instead.
In a XSLT you can use XPath 1.0 function "translate()" to delete characters:
https://www.w3.org/TR/1999/REC-xpath-19991116/#function-translate
(eg. "translate(., '👍', '')" with empry replacement string)
The problem is that you need to define what you consider an emoji.
You can easily exclude all unicode characters above BMP (Basic Multilingual Plane).
So with unicode > Ux0FFFF.
But do you consider clock symbols as unicode as well
https://commons.wikimedia.org/wiki/Category:U%2B23F0
or chess pieces?
https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode
The problem you have is to exactly define "what" you want to remove.
If you know that, doing the removal with XSLT/GatewayScript is not difficult.
------------------------------
Hermann Stamm-Wilbrandt
Compiler Level 3 support, IBM DataPower Gateways
IBM
Boeblingen
Original Message:
Sent: Thu April 10, 2025 12:57 PM
From: D@viiid
Subject: Remove emoji from input request
I mean into datapower MPG :)
------------------------------
D@viiid
Original Message:
Sent: Thu April 10, 2025 12:57 PM
From: D@viiid
Subject: Remove emoji from input request
Hello all
IS there a way to remove all emoji contains into input request
Example of request
<xml>
<mail_body>
<CorpsMail>Le jeu. 10 avr. 2025 à 17:39, a écrit : > > > Le jeu. 10 avr. 2025 à 17:37, a > écrit : > >> >> >> Le jeu. 10 avr. 2025 à 17:29, a >> écrit : >> >>> >>> >>> Le jeu. 10 avr. 2025 à 15:11, a >>> écrit : >>> >>>> 😁☺️🥰😘😚😃😀😁 >>>> >>>> Le jeu. 10 avr. 2025 à 12:03, a >>>> écrit : >>>> >>>>> >>>>> >>>>> Le mer. 9 avr. 2025 à 16:50, a >>>>> écrit : >>>>> >>>>>> dz >>>>>> >>>>></CorpsMail>
</mail_body>
</xml>
------------------------------
D@viiid
------------------------------