Mendix REST API - Handling Issue with Dutch words

0
I'm facing an issue while calling a REST API from mendix.We are passing the username in HTTP Header, but some username contains Dutch words such as:ä, ö, ë The target API only accepts alphaneumeric characters, so the API call fails when the username contains these Dutch words.Has anyone implemented this in mendix? Is there any built-in function or any suggesstion would be greatly appreciated.
asked
2 answers
1

The Community Commons module in the Marketplace has a function called StringSimplify. This will convert the characters with diacritics to those without, so "ä, ö, ë" will become "a, o, e". Use it to create a local variable of the username with these characters converted that you can use as their username in the API.


I hope this helps!

answered
1

If you want to remove all accents etc you could create a java action that accepts a string parameter StringInput and returns a normalized string. The following first splits a character like é to e', then removes the accents.


import java.text.Normalizer;
[...]
String s = Normalizer.normalize(InputString, Normalizer.Form.NFD);
s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return s


For example input: Öñíâè results in Oniae

Whether or not this is a decent approach to exchange usernames I leave up to you.

answered