Utf8_encode () and utf8_decode functions. The utf8_encode () function encodes the ISO-8859-1 string into UTF-8. Utf8_encode (string); * $ str Hello, world !; Define the string $ resultutf8_decode ($ str); encode the conversion echo utf8_encode () function to encode the ISO-8859-1 string as UTF-8.
Utf8_encode (string );
*/
$ Str = "Hello, world! "; // Define a string
$ Result = utf8_decode ($ str); // Encode and convert
Echo $ result; // output the conversion result
// Instance 2
/*
The utf8_decode () function decodes UTF-8 strings into ISO-8859-1.
This function converts a UTF-8 encoded ISO-8859-1 string to a single-byte ISO-8859-1 string.
If the operation succeeds, the function returns the decoded string; otherwise, false.
Utf8_decode (string)
*/
$ Str = "hello world! "; // Define a string
$ Result = utf8_decode ($ str); // Encode and convert
Echo $ result;
$ Result = utf8_encode ($ result); // Encode and convert
Echo $ result; // output the conversion result
?>
The http://www.bkjia.com/PHPjc/632343.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632343.htmlTechArticleutf8_encode () function encodes the ISO-8859-1 string into UTF-8. Utf8_encode (string); */$ str = Hello, world !; // Define the string $ result = utf8_decode ($ str); // Encode and convert echo...