Reputation: 878
I' using PHP CURL to get the page. I post data to the page and when I output the response I get bunch of characters like this:
‹˙˙”MkÂ@E÷ţŠ
I realize this is an encoding problem.
After I set default charset to UTF-8 in php.ini the output is different but still unreadable:
�����Mk�@E
When I go to the page and manually submit the form page displays fine in a browser, but when I output trough PHP using CURL to make post and output response it is unreadable. How do I fix this, how to set encodings and where?
Upvotes: 1
Views: 895
Reputation: 63
I am using CE characters and I had very similar problems before: it did not help just having all my pages utf-8 everywhere as page encoding, BUT you also need to check that all of your files - php, js, css etc. - are actually physically encoded in utf-8 too.
For this purpose I am using great Notepad++, just go to ENCODING -> Convert to utf-8
Notepad++ sometimes do not know that you saved your file(s) in utf-8 and thinks it is for example ANSI: if you do not notice that and save it like that your problem may repeat once again, so I learned somewhere this nice little trick: use that Convert to utf-8"in Notepad++ + just put this somewhere at the top of your files (I am using this for php so I show php example):
<?php //Útf-8 ľščťžýáíéúäôň
# YOUR SCRIPT HERE
?>
This way it will always be recognized as UTF-8 encoded file (without this I had from time to time problems with detecting my files as utf-8 tho they were encoded like that!)
Hope this helps a bit for those that did all right (webpages encoded as UTF-8) and still having this strange characters issues
Upvotes: 1
Reputation: 3372
Make sure that you are using UTF8
everywhere!
php header()
<?php header("Content-type: text/html; charset=utf-8"); ?>
and
html meta
tag
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
You can convert your input encoding to utf-8 using iconv()
For e.g.
$data = iconv("Windows-1252","UTF-8",$data);
You can find your encoding of the text received using mb_detect_encoding()
Upvotes: 0