-
- < ?php
- header("content-type: text/html; charset=utf-8");
- echo mb_convert_encoding("You are my friend", "utf-8", "gbk ");
- ?>
Copy code
2, gb2312 to big5 encoding conversion
-
- < ?php
- header("content-type: text/html; charset=big5");
- echo mb_convert_encoding("You are my friend", "big5", "gb2312");
- ?>
-
Copy the code
But to use the above function, you need to install it but you need to enable the mbstring extension library first.
Another function iconv in php is also used to convert string encoding, and its function is similar to the function above.
Example:
-
-
- $content = iconv(”gbk”, “utf-8″, $content);
- $content = mb_convert_encoding($content, “utf-8″, “gbk”);
Copy code
|