After a while of php + mssql, I feel that mssql does not support encoding very well (in fact, I am still not sure about it), but I have not been eager to change the database, so I have to wait for a while, an error occurred while submitting the data today.
After a while of php + mssql, I feel that mssql does not support encoding very well (in fact, I am still not sure about it), but I have not been eager to change the database, so I have to wait for a while, an error occurred while submitting the data today.
Because the content of the submitted ntext field is large, it is about 220 KB, which leads to my misunderstanding that it is an error caused by the article being too long. I checked the php configuration and found that the support for mssql. textsize in php is already 400 Kb. Why is there an error? After opening the error, we found that it was not a long article, but an error caused by encoding. The error is as follows:
The Code is as follows: |
Copy code |
Notice: iconv () [function. iconv]: Detected an illegal character in input string in .... |
The English language is really bad, but I know that the iconv () function has a problem. Google Translate: illegal characters are detected in the input string. Suddenly realized.
Locate the problem on the internet according to the error prompt, that is, add // IGNORE to the second parameter of iconv (), that is, IGNORE the error. The Code is as follows:
The Code is as follows: |
Copy code |
Iconv ("UTF-8", "gbk // IGNORE", $ str ); |
Test and submit successfully.
Note: The gbk range is larger than that of gb2313, so the error rate of gbk encoding is smaller than that of gb2313.