Answer the question
In order to leave comments, you need to log in
Why can there be encoding problems in PHP for some operations?
There were problems when integrating with some services - the json_encode command returns an empty string when encoding an array to json. During debugging, it turned out that part of the data in the array is in ISO-8859-1 encoding.
The same happens when writing data to a file.
The array is formed from two sources - data from the database and data hard-core in the code in files in UTF-8.
Two different scripts behave differently - in one, the data that is added in the code and written to the file using file_put_contents in this final file is in UTF-8, and the data from the database is in ISO-8859-1.
Such an array, when trying to get json, turns into an empty string.
In the other, all data is written to the file in ISO-8859-1, and is perfectly displayed in the browser as UTF-8 and is perfectly converted to json.
I found out about the ISO-8859-1 encoding after transcoding on Lebedev's website.
Php parameters are all UTF-8. ISO-8859-1 does not appear anywhere at all.
I don't even know where to dig.
Bitrix tag despite the fact that the site is on Bitrix, but I think it doesn’t matter at all.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question