Forum Moderators: coopster

Message Too Old, No Replies

Please help. black diamond in ouput

black diamond where ever two spaces are

         

cdog863

12:59 am on Sep 5, 2009 (gmt 0)

10+ Year Member



Hi,

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]

cdog863

6:28 am on Sep 5, 2009 (gmt 0)

10+ Year Member



p.s. gere is my output string

$feattext = stripslashes(strip_tags(preg_replace('~\s{2,}~', ' ', trim($row['fulltext'])), "<b><strong><img><br><p><a><span>"));

coopster

2:55 pm on Sep 5, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What type of header are you sending out with your html? utf8?

cdog863

8:41 pm on Sep 6, 2009 (gmt 0)

10+ Year Member



yes utf8

<!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" />

coopster

3:45 pm on Sep 9, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I actually meant in the HTTP headers sent before this content. You can use a tool like LiveHttpHeaders for Firefox to view them.

cdog863

4:26 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



http://mysite

GET /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

AlexK

5:05 pm on Sep 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi cdog863.

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).

cdog863

7:07 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



Ok I have added this to my script. These are the very first lines of the page.

<?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?

coopster

3:16 pm on Sep 10, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Not sure, yet. Try validating [validator.w3.org] your html, that DOCTYPE looks invalid.