PHP: imap_utf7_encode - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

imap_utf8 imap_utf7_decode

Last updated: Fri, 26 Jan 2007

view this page in

# imap_utf7_encode

(PHP 3 >= 3.0.15, PHP 4, PHP 5)

imap_utf7_encode -- Converts ISO-8859-1 string to modified UTF-7 text

## Описание

string imap_utf7_encode ( string data )

Converts `data` to modified UTF-7 text.

This is needed to encode mailbox names that contain certain characters which are not in range of printable ASCII characters.

## Список параметров

`data`

  An ISO-8859-1 string.

## Возвращаемые значения

Returns `data` encoded with the modified UTF-7 encoding as defined in RFC 2060, section 5.1.3 (original UTF-7 was defined in RFC1642).

## Смотрите также

imap_utf7_decode()

add a note User Contributed Notes
imap_utf7_encode
31-Jul-2006 07:10
`This encoding will not work for cyrus imapservers and you might have problems with other mail clients.
Use mb_convert_encoding($str, "UTF7-IMAP","ISO-8859-15") instead.
ps: mb_convert_encoding() requires building php with --enable-mbstring option`
02-Nov-2005 03:01
`Note that php4 (4.4.0) will encode IMAP folders in a way that no other program will be able to decode them back.
$ php4 <<EOF
> <?php
> echo "ENCODED: " . imap_utf7_encode("�") . "\\n";
> ?>
> EOF
ENCODED: &w5w-
Now try to decode the result string ("&w5w-") using e.g. javamail or python's imaplib, or if you don't like these languages - create an IMAP folder using PHP and try to display it in an IMAP client (mutt, thunderbird, outlook, whatever...)`
marcelo at maccoy dot com dot br
07-Mar-2005 05:48
`<?php
/**
* @return encoded string
* @param string $str
* @desc Convert str to UTF-7 imap default mailbox names
(the imap_utf7_encode don t built the same result)
*/
function getEncodedUtf7($str){
if(!$str){
echo "error: you need to give a string parameter.";
return false;
}
# change spaces by entropy because mb_convert fail with spaces
$str=ereg_replace(" ","xyxy",$str);
# if mb_convert work
if($str=mb_convert_encoding($str,"UTF-7")){
# change characters
$str=preg_replace("/\+A/","&A",$str);
# change to spaces again
$str=preg_replace("/xyxy/"," ",$str);
# return encoded string
return $str;
# else
}else{
# print error and return false
echo "error: is not possible to encode this string '$str'.[".
imap_last_error().
"]";
return false;
}
}
?>`
hartmut at six dot de
15-Mar-2000 10:14
`this function was buggy up to php3.0.15 / php4beta4pl1`
add a note
imap_utf8 imap_utf7_decode

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST