Asked  9 Months ago    Answers:  5   Viewed   44 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.

Wednesday, March 31, 2021
answered 9 Months ago

The core PHP string functions all assume 1 character = 1 byte. They have no concept of different encodings. To figure out how many characters are in a UTF-8 string (not how many bytes), use the mb_strlen equivalent and tell it what encoding the string is in:

echo mb_strlen('????', 'UTF-8');
Wednesday, March 31, 2021
answered 9 Months ago

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, May 28, 2021
answered 7 Months ago

Try passing the encoding parameter to mb_substr, as such:

print mb_substr('éxxx', 0, 1, 'utf-8');

The encoding is never detected automatically.

Saturday, May 29, 2021
answered 7 Months ago

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');
Sunday, August 22, 2021
Scheff's Cat
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :