If you’re trying to get the contents of a page which has an utf-8 encoding using PHP’s socket functions (fsockopen, fgets, etc) may be you take some strange text which is parted or sliced into unknown parts like this :
<a href=http://www.focusoncode.com 1f target=' 33
You can clearly see that an url line is splitted into five lines and some chars are thrown away weirdly.
At last i found the problem occured for the header that i’ve used. I’ve used HTTP/1.1 while creating the request. If I request the page by this header i got strings weirdly. So, i change the header to old one : HTTP/1.0. Then it works fine for me.
If you encounter problems like that above you must feel free to change the header from HTTP/1.1 to HTTP/1.0
Tags: php, programming, sockets, solutions, utf-8
Entries (RSS)