Viewed   71 times

I have a PHP file with one simple echo function:

echo '????????????';

but when I access that page i get this:


Can someone help me? I also have my page encoding set to UTF-8, and I know it, because all of the browsers i used said so. I also do this before the echo function:


What does this do? Does it help me? All I need is to be able to echo a static Japanese string.




I got it. I just had to set the mbstring extension settings to handle internal strings in UTF-8. Thas extension is standard with my build of PHP 5.3.0.

Saturday, October 8, 2022

It sure does look to me that id_key is being passed by reference.

Some of those PDO libraries are coded in C. It's quite possible that in the innards the variables get corrupted there.

TBF you're passing a string as an argument that expects a numeric value, so from the standpoint of the functions you're using, the new value is the same as the old value (most text strings not containing digits = 0).

Friday, December 23, 2022


This answer is meant for situations where it's not possible to run/install the 'intl' extension, and only sorts strings by replacing accented characters to non-accented characters. To sort accented characters according to a specific locale, using a Collator is a better approach -- see the other answer to this question for more information.

Sorting by non-accented characters in PHP 5.2

You may try converting both strings to ASCII using iconv() and the //TRANSLIT option to get rid of accented characters;

$str1 = iconv('utf-8', 'ascii//TRANSLIT', $str1);

Then do the comparison

See the documentation here:

[updated, in response to @Esailija's remark] I overlooked the problem of //TRANSLIT translating accented characters in unexpected ways. This problem is mentioned in this question: php iconv translit for removing accents: not working as excepted?

To make the 'iconv()' approach work, I've added a code sample below that strips all non-word characters from the resulting string using preg_replace().


setLocale(LC_ALL, 'fr_FR');

$names = array(
   'Zoey and another (word) ',
   'Émilie and another word',

$converted = array();

foreach($names as $name) {
    $converted[] = preg_replace('#[^ws]+#', '', iconv('UTF-8', 'ASCII//TRANSLIT', $name));


echo '<pre>'; print_r($converted);

// Array
// (
//     [0] => Amber
//     [1] => Emilie and another word
//     [2] => Zoey and another word 
// )
Wednesday, November 23, 2022

str_split does not work with multi-byte characters, it will only return the first byte - thus invalidating your characters. you could use mb_split.

Thursday, October 20, 2022

You should change your file encoding to UTF-8 and set the header on the website to UTF-8.

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

in HTML5 you should use:

<meta charset="utf-8" /> 

or in php

header('content-type: text/html; charset=utf-8');
Monday, November 14, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :