PHP: Make Site Unicode Compatible
How can i开发者_如何学JAVA make my site unicode compatible to support more languages other than english.
Thanks
For PHP:
First of all you need to set your scripts encoding to utf8 (IDEs/Editors like Eclipse/Notepass++ or Ultraedit are able of this). If you will output xhtml then you maybe add:
<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />
</head>
to force the browser to use utf8.
If youre working with for example xml documents, databases(many of them support utf8) or any other sources which are not utf8 than have a look at following functions for conversion in the php documentation:
string utf8_encode ( string $data );
string utf8_decode ( string $data );
string iconv ( string $in_charset , string $out_charset , string $str );
Here the links to the documentation:
http://www.php.net/manual/en/function.utf8-decode.php
http://www.php.net/manual/en/function.utf8-encode.php
http://www.php.net/manual/en/book.iconv.php
As an addition try:
http://de.php.net/manual/en/book.mbstring.php
精彩评论