M
M
marsep2015-08-28 20:45:20
Yii
marsep, 2015-08-28 20:45:20

How can I convert the given text into the correct encoding?

Hello! There is a text:

Locking: 10.12.1995
E-Mail
: 4000.00
ñðîîêêêààààíííí ääää
:::::::::: :é
:: :ééééééééééééé

I can’t bring it back to normal through PHP code, which I just haven’t tried. It seems to be nothing like that, but it doesn't work. Tried through iconv and mb_convert_encoding, but to no avail. Some online decoders output this text normally and everything works out for them, but their tips do not help either. The text itself comes to the code from the mail, in the properties of the letter it says that the encoding is ASCII. Has anyone encountered similar decoding difficulties? Thanks in advance!
PS Yandex itself (mail) displays the text correctly, but this is not very important - when collecting text from mail and writing, for example, to a file, as well as when using these functions, nothing happens, it displays either in the same form or completely different crocozyabrs - if you choose the wrong encoding...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
marsep, 2015-12-02
@marsep

iconv('CP1251', 'UTF-8', '');

A
Andrew, 2015-08-28
@OLS

The text you provided is Win-1251 characters, i.e. "A"=0xC0 ... "i"=0xFF, converted to UTF, not according to the rules for Cyrillic (to get 0x0410...0x044F), but simply as regular extended ASCII (0x00C0..0x00FF). Those. some of the processes that encode from ASCII to UTF does not understand how to work with Win-1251 Cyrillic. For the reverse conversion, in fact, you need to decode UTF->ASCII, and then declare the resulting Win-1251 data block and convert Win-1251->UTF forward. I don't know how to do it in PHP, sorry...
PS By the way, post an example of your file somewhere in its original form. Maybe it is your code that does not understand the encoding, if, according to your words, everything is displayed correctly in the web interface.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question