Javascript to replace characters ä ü ö ß …

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Javascript to replace characters ä ü ö ß …

Viewing 2 reply threads
  • Author
    Posts
  • September 28, 2022 at 1:35 AM #48034

    Chris Ju
    Participant

    Hi,

    i’m using the following java script code to replace characters:

    
    var chars = {'ß':'ss','&':'und','.':'','ö':'oe','ä':'ae','ü':'ue','é':'e','è':'e','Ö':'Oe','Ä':'Ae','Ü':'Ue','É':'E','È':'E'};
    var nachname = (record.getFieldValue('fld-eef248f9679f47eb98598b22133da6ea').toString().replace(/[ß&.öÖäÄüÜéÉèÈ]/g, m => chars[m])).toString().replace(/\s/g, '%20');
    

    Nothing is replaced with this code.

    Adding for example UTF-16 code for character ‘ü’ -> ‘\\u00fc’ to the second variable string:

    
    var chars = {'ß':'ss','&':'und','.':'','ö':'oe','ä':'ae','ü':'ue','é':'e','è':'e','Ö':'Oe','Ä':'Ae','Ü':'Ue','É':'E','È':'E'};
    var nachname = (record.getFieldValue('fld-eef248f9679f47eb98598b22133da6ea').toString().replace(/[ß&.öÖäÄüÜéÉèÈ\\u00fc]/g, m => chars[m])).toString().replace(/\s/g, '%20');
    

    leads for for example with the text “Stümper” to

    ‘Stundefinedmper’

    Even if i add the UTF-16 code to the first variable, results to the same undefined issue.

    Does anyone have an short idea to solve that?

    Thanks
    Chris

    September 28, 2022 at 7:52 AM #48035

    Daniel Leu
    Participant

    This works for me:

    const nachname_id = 'fld-xxx';
    const chars = {'ß':'ss','&':'und','.':'','ö':'oe','ä':'ae','ü':'ue','é':'e','è':'e','Ö':'Oe','Ä':'Ae','Ü':'Ue','É':'E','È':'E'};
    
    let nachname = record.getFieldValue(nachname_id);
    nachname = nachname.replace(/[\u00f6ß&.öÖäÄüÜéÉèÈ]/g, m => chars[m]).replace(/\s/g, '%20');
    • This reply was modified 2 years, 2 months ago by Daniel Leu.
    • This reply was modified 2 years, 2 months ago by Daniel Leu.
    September 29, 2022 at 12:18 AM #48047

    Chris Ju
    Participant

    Thanks a lot! I found out that also my code works. It was an issue with copying & pasting the “ü” from a pdf file. I only tested the code with this entry … It was great that you changed the character!

Viewing 2 reply threads

You must be logged in to reply to this topic.