Php iconv function usage method _ php skills. To install the PHP module in unix, you need to re-compile PHP. to install the template in Windows, you only need. you can open the corresponding dll for the configuration in ini. for example, to add the support for the gb library, you need to install the PHP module in the following unix environment, re-compile PHP, and install the template in Windows, you only need. you can open the corresponding dll for the configuration in ini. for example, to add the support for the gb library, you need the following settings:
Extension_dir = "C:/ipaddr/php/extensions /"
(Note: it is recommended to write the full address and add/to it later. in many cases, the dll of other modules cannot be loaded because the setting is incorrect)
Open again
Extension = php_gd2.dll
However, if you install iconv. dll, follow the above method to enable the iconv module after enabling php_iconv.dll. the following configuration is required:
A. Download The iconv official website
Http://ftp.gnu.org/pub/gnu/libiconv/
The following Windows version of The iconv File: libiconv-1.9.1.bin.woe32.zip
Decompress the file and copy charset.dll, iconv.dll, and iconv.exe under bin/to c:/windows/(or another system PATH)
(Ipaddr reminds you that this step is required. php_iconv.dll also calls the GNU iconv library. Therefore, install the GNU iconv library first)
B. enable php_iconv.dll in php. ini.
C. restart Apache and check whether iconv is enabled in phpinfo.
Recently, I am working on a program. I need to use the iconv function to convert the captured UTF-8 encoded page to gb2312, it is found that only the iconv function can be used to convert the captured data into less data for no reason. I was depressed for a while. I checked the information on the Internet to find out that this is a bug in the iconv function. Iconv will encounter an error when converting the character "-" to gb2312
The solution is simple. add "// IGNORE" after the code to be converted, that is, the second parameter of the iconv function, as follows:
Reference content is as follows:
Iconv ("UTF-8", "GB2312 // IGNORE", $ data)
Ignore indicates that the conversion error is ignored. without the ignore parameter, all strings after this character cannot be saved.
This iconv () function is built-in in php5. thank you.
Column
Echo $ str = 'Hi, it's coffee sale! ';
Echo'
';
Echo iconv ('gb2312', 'utf-8', $ str); // Encode the string from GB2312 to UTF-8
Echo'
';
Echo iconv_substr ($ str, 1, 1, 'utf-8'); // truncate by number of characters rather than bytes
Print_r (iconv_get_encoding (); // Obtain the encoding information of the current page.
Echo iconv_strlen ($ str, 'utf-8'); // you can specify the length of the encoded string.
// This is also applicable.
$ Content = iconv ("UTF-8", "gbk // transcoder", $ content );
?>
...