A
A
Alexander Ulo2017-05-18 11:33:46
PHP
Alexander Ulo, 2017-05-18 11:33:46

Base64_decode how to fix bugs?

The point is simple.
I take the message from the mail via imap_open().

$header = imap_header($mbox, $msgno);  //Достаю заголовок
$subject = $header->subject;

As a result, the header of the letter is encoded in base64:
=?UTF-8?B?RndkOiDQn9C+0YHRgtGD0L/Qu9C10L3QuNC1INC90LAg0YHRh9C10YI=?=
When decoded, bugs come out.
If you use a service like online-decoder.com, then everything decodes perfectly with the mark (BASE64->UTF-8)
The page itself, where echo is done in utf-8.
And the same phrase when translated back to base64:
0J/QvtGB0YLRg9C/0LvQtdC90LjQtSDQvdCwINGB0YfQtdGC
Where is my cant? or what am I missing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2017-05-18
@Salexer

imap_utf8()
imap_mime_header_decode()

S
Saboteur, 2017-05-18
@saboteur_kiev

The '=' sign in base64 may be only at the very end, one or two, depending on the end of the triad, or may not be.
Characters '?' there shouldn't be a question.
Based on your line, try to cut off the text between the question marks - in my opinion, they are the ones that separate the desired text.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question