I'm trying to use a multi-byte string replacement function with some Japanese in my script, but it's failing due to one of the strings being compared being stuck in ASCII. The script itself is saved as UTF-8.

$text = iconv('ASCII', 'UTF-8', $text);
//$text = utf8_encode($text);
echo "Encoding: ".mb_detect_encoding($text);

I've tried either of the two methods above, but regardless of which I pick, it still echoes 'Encoding: ASCII'. I'm pretty new to this, so I'm probably missing something here, but is there any obvious reason why both of these might fail?
Thanks!

    Well, if it really is ASCII then there's nothing to encode: all of the characters with ASCII encodings are encoded in exactly the same way in UTF-8.

    In other words, if you have a string encoded in ASCII then it's already encoded in UTF-8 as well.

      Write a Reply...