Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Script Talk › Javascript to replace characters ä ü ö ß …
- This topic has 2 replies, 2 voices, and was last updated 3 years, 1 month ago by 
Chris Ju.
 
- 
		AuthorPosts
 - 
		
			
September 28, 2022 at 1:35 AM #48034
Chris JuParticipantHi,
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
ChrisSeptember 28, 2022 at 7:52 AM #48035
Daniel LeuParticipantThis 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 3 years, 1 month ago by 
Daniel Leu.
 - 
		This reply was modified 3 years, 1 month ago by 
Daniel Leu.
 
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksSeptember 29, 2022 at 12:18 AM #48047
Chris JuParticipantThanks 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!
 - 
		This reply was modified 3 years, 1 month ago by 
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.