S
S
Superdsa2020-05-02 01:28:20
PHP
Superdsa, 2020-05-02 01:28:20

How to correctly convert win-1252 to utf-8 from an array?

There is an array obtained from the database
, some elements are encoded in win-1252 how to decode

[
    {
        "description": "Описание0",
        "date": "2020-05-01 04:15:13"
    },
    {
        "description": "Описание1",
        "date": "2020-05-01 03:07:00"
    },
    {
        "description": "Описание2",
        "date": "2020-05-02 00:08:30"
    },
    {
        "description": "Ð\u0090ктивациÑ\u008f купона ",
        "date": "2020-05-02 00:17:32"
    },
    {
        "description": "Описание4",
        "date": "2020-05-02 00:20:29"
    },
    {
        "description": "Описание5 ",
        "date": "2020-05-02 00:21:39"
    },
    {
        "description": "Ð\u0090ктивациÑ\u008f купона millen",
        "date": "2020-05-02 00:22:43"
    },
    {
        "description": "Описание6",
        "date": "2020-05-02 00:25:22"
    },
    {
        "description": "Описание7,
        "date": "2020-05-02 00:29:00"
    },
    {
        "description": "Ð\u0090ктивациÑ\u008f купона millen",
        "date": "2020-05-02 00:29:22"
    },
    {
        "description": "Описание8",
        "date": "2020-05-02 00:49:31"
    },
    {
        "description": "Ð\u0090ктивациÑ\u008f купона testcupon_hyle",
        "date": "2020-05-02 00:51:38"
    }
]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2020-05-02
@AUser0

It looks like your problem happened due to the fact that during INSERTs, the connection to the database was made with the wrong encoding (charset). You need to determine (via "SET NAMES='CP1251';" for example) what encoding was used, and with this encoding to read these incorrect data, then they will be correct. And then, through the connection with the correct encoding, overwrite them, and everything will fall into place ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question