0
votes

I've created a csv import allowing users to upload their csv full of info on a Mysql database and displaying them on another webpage.

Now, some users are french and some others russian. So I'd need to be able to handle both sets of characters, but I find myself having problems with both.

I tried to add the utf8_decode tags before the variables but the situation doesn't change.

I'd like to know wether there is a general solution allowing to deal with both sets of characters in the same page??

ps in a previous page I was dealing with I handled it by passing the utf8_decode tag everytime I was dealing with a French variable, and by putting nothing everytime dealing with a russian variable. But in this case the trick doesn't work.

Thanks in advance. "the world of characters sets is a weird beist..." marko.c

2
if you blindly call utf8_decode, but the users didn't upload utf8 text, you're just going to be trashing things further. You need to identify the charset used by the uploaded file FIRST. - Marc B
Thanks for the quick reply. All csv are uploaded in UTF8 (forgot to mention). - marko c.
ok sorry but I just noticed that the UTF8 encryption is actually recognized, it is the special characters that aren't recognized. otuput example being -> о�?ен�? важен, вед�? кон�?е - marko c.
One, UTF-8 is not "encryption". Two, I suspect you're reading your input file wrong. Check exactly what bytes are going around. - Karol S

2 Answers

0
votes

You could convert everything to UTF-32 just to be sure, you could try something like:

if(!mb_detect_encoding($csv, 'UTF-32', true)){
    iconv(mb_detect_encoding($csv, mb_detect_order(), true), "UTF-32", $csv);
}
0
votes

Ok so in the end the whole problem was in the csv upload. once added the following line to the csv upload mysql_query("SET NAMES 'UTF8'"); everything worked properly. No need to recall any type of encoding nor decoding UTF8, both russian and french characters simpley work well.

cheers, thanks