[PHP] correct character decoding

2011-08-30 Thread Merlin Morgenstern
Hi there, I am trying to find a solution for decoding the same string from 2 different character sets (UTF-8, Latin-1) Looks like in the case of latin-1 I need to add utf8_encode before to get the same results. Here is an example // utf-8 $input = urldecode('%20%C3%9Cbersetzung%20franz');

Re: [PHP] correct character decoding

2011-08-30 Thread Louis Huppenbauer
Why don't you just check if the string is utf8 or not, and change convert it accordingly? $out = trim((mb_detect_encoding($input, 'UTF-8', 'ISO-8859-1') == 'UTF-8' ? $input : utf8_encode($input))); It may not be the most elegant version, but I can't think of anything simpler right now.

Re: [PHP] correct character decoding

2011-08-30 Thread Merlin Morgenstern
Am 30.08.2011 14:12, schrieb Louis Huppenbauer: Why don't you just check if the string is utf8 or not, and change convert it accordingly? $out = trim((mb_detect_encoding($input, 'UTF-8', 'ISO-8859-1') == 'UTF-8' ? $input : utf8_encode($input))); It may not be the most elegant version, but I