Reading json. The file starts with 65279 and starts with json65279.

Source: Internet
Author: User
Tags ultraedit

Reading json. The file starts with 65279 and starts with json65279.

The loading of json files fails until today. Only ASCII encoding formats can be loaded. Because they are Chinese, they cannot be loaded in ASCII format, later, my colleague found that the first character of json is encoded as 65279. Later, Baidu gave it a bit because I edited the json file with the bom header.

The solution on the Internet is to use editplus or ultraedit software to operate to save as a UTF-8 on the line, as shown below:

1. Use editplus to remove the BOM Header
 
After the editor is adjusted to the UTF8 encoding format, a hidden character (BOM) is added before the saved file, which is used by the editor to identify whether the file is UTF-8 encoded.
Run Editplus, click the tool, select preference, select the file, select the UTF-8 ID alWays Delete the signature, and then the PHP file after editing and saving the PHP file is without BOM.


2. Use ultraedit to remove the BOM Header

After opening the file, select from the encoding format of the Save As option (UTF-8 without BOM header), OK


However, my colleague's method is to judge whether the first encoding is 65279 when reading json, and then delete the encoding.

If (int) (json [0]) = 65279) {json = json. Substring (1 );}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.