PHP Conference Fukuoka 2025

imap_utf8

(PHP 4, PHP 5, PHP 7, PHP 8)

imap_utf8Convierte texto en formato MIME a UTF-8

Descripción

imap_utf8(string $mime_encoded_text): string

Convierte el texto mime_encoded_text a UTF-8, si el conjunto de caracteres declarado es conocido por libc-client. De lo contrario, el texto proporcionado será decodificado, pero no convertido a UTF-8.

Parámetros

mime_encoded_text

Un string codificado en MIME. Las especificaciones de MIME y UTF8 están descritas en los » RFC2047 y » RFC2044.

Valores devueltos

Devuelve el string decodificado y, si es posible, convertido a UTF-8.

Ejemplos

Ejemplo #1 Uso básico de la función imap_utf8()

<?php
echo imap_utf8("Johannes =?ISO-8859-1?Q?Schl=FCter?=");
?>

Resultado del ejemplo anterior es similar a :

Johannes Schlüter

Ver también

add a note

User Contributed Notes 3 notes

up
7
esvit at mail dot ru
14 years ago
That fixed the all caps issue:

<?php
function imap_utf8_fix($string) {
  return iconv_mime_decode($string,0,"UTF-8");
}
?>
up
5
kloewer at gmail dot com
13 years ago
Use  iconv_mime_decode();<?php// This yields "Subject: Prüfung Prüfung"echo iconv_mime_decode("Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=",                       0, "ISO-8859-1");?>http://php.net/manual/de/function.iconv-mime-decode.php
up
2
marcelo at maccoy dot com dot br
20 years ago
# this script are correct with the right signs remove expression# please, ignore the later.function decode_utf8($str){       # paterns           $err="(=\?.{10,13}q\?_?|\?\=)";           $pat = "/=([0-9A-F]{2})/";            $cha="'.chr(hexdec(";       # erase null signs in string          $str=eregi_replace($err,"",$str);       # to decode with eval and replace          eval("\$str='".                  preg_replace($pat,$cha."'$1')).'",$str)                  ."';");        # return           return $str;} #Note: you can to reduce this script in 3 lines.
To Top