Forum Moderators: coopster
I have a script that pulls text from the database. the db field is utf8_general_ci.
Whenever there are two spaces in a row one space turns into a diamond with a question mark.
How can I solve this. I use Joomla K2 plugin for my users o post the articles.
From what I can tell I have all charsets correct. Any idea?
Thanks
[edited by: tedster at 2:20 am (utc) on Sep. 5, 2009]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
http://mysiteGET /mag/interview-¦-matt-goerke HTTP/1.1
Host: mysite.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: mysite.com
Cookie: phpbb3_p9tgg_k=569bed2d710821b1; phpbb3_p9tgg_u=2; phpbb3_p9tgg_sid=b618aa005a891fc2229fc60776882bda; 7e801e1d0bc23abf4efbd65486c63d2a=1ad8f00dc776533cb36af5aa09bb910f
HTTP/1.x 200 OK
Date: Wed, 09 Sep 2009 16:21:47 GMT
Server: Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.9
X-Powered-By: PHP/5.2.9
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
The Response header does NOT indicate UTF8. The Request header shows ISO-8859-1 first, & the browser would therefore quite reasonably use ISO-8859-1 as the charset, leading to strange characters whenever a non-ISO-8859-1 char appears.
Add the page coding to the Response headers is the simple answer (and yes, you would hope that the `<meta http-equiv' would do it, but clearly it is not).
<?php$db_connect = mysql_connect("localhost", "", "");
$db_select = mysql_select_db("sikmx_joomla", $db_connect);
header('Content-type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
it's still not working. am i doing something wrong?