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.