PDA

Click to See Complete Forum and Search --> : php Unicode


vbbit
Mar 2nd, 2006, 01:53 PM
Hello, I would like my blog to be a Unicode enabled site. How am I going to do that? My blog is very simple, there are fields of EntryNum, Date, Title and Content in mysql database, but I want write some characters into my entry and save it to mysql, after that retrieve those characters and display on browser. Any thoughts?

sciguyryan
Mar 2nd, 2006, 03:04 PM
Hello, I would like my blog to be a Unicode enabled site. How am I going to do that? My blog is very simple, there are fields of EntryNum, Date, Title and Content in mysql database, but I want write some characters into my entry and save it to mysql, after that retrieve those characters and display on browser. Any thoughts?

Just send the encoding format from the PHP header function, the encoding meta tag does not work unless your a bot :)

I know MysQL can store UTF-8 so you shoud be fine there also.

Cheers,

Ryan Jones

vbbit
Mar 2nd, 2006, 04:05 PM
What is encoding format from the PHP header function?

sciguyryan
Mar 2nd, 2006, 04:09 PM
What is encoding format from the PHP header function?

http://uk.php.net/header

Should help :)

If you site is an XM spec. you can use something like this:


<?php
header('Content-type: application/text-html');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>


Or the IE blocker :D

<?php
header('Content-type: application/xhtml+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
Cheers,

Ryan Jones

visualAd
Mar 2nd, 2006, 04:20 PM
PHP doesn't support unicode by default. However, you can either compile Multi-Byte String (http://uk.php.net/mbstring) support into PHP or do it your self:

http://www.randomchaos.com/documents/?source=php_and_unicode

sciguyryan
Mar 2nd, 2006, 04:25 PM
PHP doesn't support unicode by default. However, you can either compile Multi-Byte String (http://uk.php.net/mbstring) support into PHP or do it your self:

http://www.randomchaos.com/documents/?source=php_and_unicode

Wasn't the queston about MySQL support too? I know 4.1.1 suports it because our server supports it and thats what I have :)

Cheers,

Ryan Jones

visualAd
Mar 2nd, 2006, 04:32 PM
Yeah, the question was about MySql; but I assumed he might want to use PHP collect and display the information. :D

Unicode characters below 255 display fine, however, characters with a higher value will be interpreted by PHP as two separate characters. The resulting output then gets scrambled.

CornedBee
Mar 4th, 2006, 08:32 PM
header('Content-type: application/text-html');
Um, it's "text/html" - "application/text-html" doesn't exist.