Migrating data, from latin1 charset to UTF-8
I would say if you want to convert all your non-ASCII characters you won't need to do any latin1
to UTF-8
conversion what so ever. Let's say you run a function such as htmlspecialchars
or htmlentities
on your data, then all non-ASCII characters will be replaced with their corresponding entity code.
Basically, after this step, there shouldn't be any characters left that needs conversion to UTF-8
. Also, if you wanted to convert your latin1
encoding string into UTF-8
i strongly suspect utf8_encode
will du just fine.
PS. When it comes to converting bbCode
into HTML
I would recommend using regular expressions instead. For example you could do it all in a line like this:
$html_data = preg_replace('/\[(/?[a-z]+)\]/i', '<$1>', $bb_code_data);