[OpenTRV-dev] OT: replacement of danish char's inside a word

Mike Stirling EMAIL ADDRESS HIDDEN
Tue Mar 18 13:34:48 GMT 2014


Where in the system do the special characters go wrong?  I ask because 
you should really deal with these sorts of problems by making sure 
everything is speaking the same character encoding.  This will work for 
everything, not just the small set of characters you manually fix up.

eg. if you have a MySQL database you need to make sure your table 
collation is set to utf8_general_ci.

Mike

On 18/03/14 13:14, Bo Herrmannsen wrote:
> Hi
>
> anyone that can help me out with php?
>
>
> i need to replace some special danish char's with something else. This should happen no matter where they pop up.
>
>
> $string = $row['delivery_street_address'];
>
> $patterns = array();
> $patterns[0] = '*å*';
> $patterns[1] = '*æ*';
> $patterns[2] = '*ø*';
>    
>    
> $replacements = array();
> $replacements[3] = '/x7D';
> $replacements[2] = 'X';
> $replacements[1] = '/x7C';
>
> echo preg_replace($patterns, $replacements, $string);
>
>
>
> the address in this case is: Sandkæret 1,1,1
>
> but these 3 letters can pop up anywhere in any numbers
>
> all help is welcome :-D
>
>
> _______________________________________________
> OpenTRV-dev mailing list
> EMAIL ADDRESS HIDDEN
> http://lists.opentrv.org.uk/listinfo/opentrv-dev



More information about the OpenTRV-dev mailing list