Replace Special Characters#
Description#
This snippet replaces special characters in a given string with their corresponding standard characters. It uses two arrays: one containing the special characters and the other containing the replacement characters. The glosub_array
function performs the replacement, resulting in a clean string with special characters substituted.
Snippet#
<mvt:assign name="l.special_chars" value="miva_array_deserialize('Á,á,À,Â,à,Â,â,Ä,ä,Ã,ã,Å,å,Æ,æ,Ç,ç,Ð,ð,É,é,È,è,Ê,ê,Ë,ë,Í,í,Ì,ì,Î,î,Ï,ï,Ñ,ñ,Ó,ó,Ò,ò,Ô,ô,Ö,ö,Õ,õ,Ø,ø,ß,Þ,þ,Ú,ú,Ù,ù,Û,û,Ü,ü,Ý,ý,ÿ')" />
<mvt:assign name="l.settings:replace_chars" value="miva_array_deserialize('A,a,A,A,a,A,a,A,a,A,a,A,a,AE,ae,C,c,D,d,E,e,E,e,E,e,E,e,I,i,I,i,I,i,I,i,N,n,O,o,O,o,O,o,O,o,O,o,O,o,s,T,t,U,u,U,u,U,u,U,u,Y,y,y')" />
<mvt:assign name="l.settings:test_string" value="'Ýó Ðüðê'" />
<mvt:assign name="l.settings:clean_test_string" value="glosub_array( l.settings:test_string, l.special_chars, l.settings:replace_chars )" />
&mvte:test_string; -> &mvte:clean_test_string;