Reputation: 61
I am creating a simple registration form, in which you must type your nickname into textarea. The problem occurs when user uses polish characters (ś,ż,ć etc.). When I try to display the whole string by echo it looks just how it should, but when I try to display only one character then it shows this weird � symbol.
function ech($nam)
{
echo $nam;
echo "</br>";
echo $nam[1];
}
$te = $_POST['sth']; //$te equals "śżć" now
ech($te);
Output:
śżć
�
Upvotes: 0
Views: 106
Reputation: 3586
Using an offset for a character of a string like $nam[1]
actually only returns a single byte, but the characters are multiple bytes. use multibyte-safe string functions like mb_substr($nam, 0, 1)
Upvotes: 2