I switched to utf-8 character set and here is a problem…
step by step how it works (and it works!):
< textarea name=”comment” >blahblahblah< /textarea > —–> javascript event —–> sends blahblahblah text using ajax POST method —–> part1.php file receives $comment=$_POST[“comment”]; successfully and displays it with no problems on the html page below the textarea.
But everything is perfect if that text is not modified, or could be modified but should contain only English letters. otherwise, rectangles are on the page instead of cyrillic letters.
here is a code of part1.php and several results on html page:
$comment=$_POST["comment"];
echo $comment."|".strlen($comment)."|".substr($comment,0,1);
Entered in the textarea: “Hello”. Displayed below the textarea: hello|5|h //OK
Entered in the textarea: “Hello,Варна”. Displayed below the textarea: Hello,Варна|16|H //OK
Entered in the textarea: “Варна”. Displayed below the textarea: nothing, “Error on page” is displayed on the browser left down side as for javascript errors.
If I remove substr($comment,0,1) and write “Варна”, it will display Варна|10 without any mistakes.
Why is this happening so I can’t extract any part of that string to modify it?… Any ideas?
Thank you.
You should use
mb_strlenandmb_substr.