Hello, I need some help replacing special chars like 'à,é,è,...' in strings with their corresponding ascii char values. I do know the string replace method thus replacing these special chars with normal alphabets, with the example below:

`$vSomeSpecialChars = array("á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", "ñ", "Ñ");
$vReplacementChars = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "n", "N");

$vReplacedString = str_replace($vSomeSpecialChars, $vReplacementChars, $vOriginalString);`

However, I would like to do the same with instead using for example ascii_char(224) instead of replacing with normal alphabets, however I do not know how to proceed exactly if the special character is found in the middle of a string, where I would need to concatenate something like for example: "Holà, comos...", where it should be like "Hol"||ascii_char(224)||", comos..." and it may be possible that other special chars are present in the strings which follow. Thus I would need some help in finding these chars positioning and then add the concatenation sign, ||, and then continue my strings, else if the end of a string, not add the concatenation sign after the ascii_char(). Am using firebird for DBs with IBExpert, and it supports the ascii_char() function. However it is only that my level of programming in delphi is still very low to be able to clearly solve this problem, so pls be patient with me...

With Pos you can find the position of that character. Then you can determine if it is at the start or end, or in the middle.

Another option would be to use a regular expression.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.