Asking for advice to output an array containing Chinese characters to a file, and other places to call to read arrays

Source: Internet
Author: User
Asking for advice to output an array containing Chinese characters to a file, and other places to call to read arrays
The thing to note here is that you need to think about coding, and I want to be able to access both GBK and UTF8 characters.
Normal access with JSON prior to UTF8
But it's not going to change to GBK.
First of all, here is the GBK or UTF8 is unknown, that is, to be able to run under both of these codes. Without having to manually modify


Reply to discussion (solution)

Easy entry is a big rule.
You are obviously in control of the "out", so it should not be output by indefinite encoding, but should be determined to output only one encoding
As far as your data source is inconsistent with the predetermined output code, the conversion is good.

Ask: Other places call Read array
What does it mean?
Direct file function operation?
Include
Function call?

Is it OK to return the data to an interface that returns JSON data?

Asking for advice to output an array containing Chinese characters to a file, and other places to call to read arrays
The thing to note here is that you need to think about coding, and I want to be able to access both GBK and UTF8 characters.
Normal access with JSON prior to UTF8
But it's not going to change to GBK.
First of all, here is the GBK or UTF8 is unknown, that is, to be able to run under both of these codes. Without having to manually modify

Why not GBK?

JSON is best used with UTF-8, or it may be garbled after being used by JavaScript.

Is it OK to return the data to an interface that returns JSON data? Of course I do. The problem with JSON is that GBK JSON does not support Chinese if you encode with Icov and don't know if it is GBK or UTF8

The key is how other programs read?

The key is how other programs read? I am writing a discuz plugin because DZ has more than one encoding so do not know what the user is using encoding, so save the time to be based on the user's code to save

Since the plugin is written for Discuz, you can get the encoded information from the Discuz
is the encoding used in the config/config_global_default.php already set?
$_config[' db ' [' 1 '] [' dbcharset '] = ' ... ';//Database Character set
$_config[' Output ' [' charset '] = ' ... ';//page character set

It is hard to imagine that the write plugin does not take advantage of the system's existing environment settings

The data written to the file, preferably with the results generated by Var_export, written in the form of PHP code
This allows you to use the include to read back when you reuse it.

  • 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.