Read JSON, file 65279 is not recognized at the beginning

Source: Internet
Author: User
Tags ultraedit

Loading the JSON file today is not successful, only ASCII encoded format can be loaded, because it is Chinese, so it can not be used in ASCII format, later my colleague found that the first character of the JSON encoding is 65279, and then Baidu a bit, because I edited this JSON file with text So that it has a BOM header.

The solution on the web is to use software such as EditPlus or UltraEdit to save as UTF-8, as follows:

1. Use EditPlus to remove BOM head

After the editor is resized to UTF8 encoded format, the saved file will be preceded by a string of hidden characters (also known as BOMs), used by the editor to identify whether the file is encoded in UTF8.
Run EditPlus, click Tools, select Preferences, select files, UTF-8 identity Select always delete signatures, and then edit and save php files without BOM.


2. Use UltraEdit to remove BOM head

After opening the file, select the "Save as" option in the encoding format (UTF-8 no BOM header), OK.


However, my colleague's method is to read the JSON to determine whether the first encoding is 65279, and then delete the character encoding

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


Read JSON, the beginning of file 65279 is not recognized

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.