note 17571 added to function.bin2hex

From: Date: Fri, 14 Dec 2001 16:47:01 +0000
Subject: note 17571 added to function.bin2hex
Groups: php.notes 
Request: Send a blank email to php-notes+get-22614@lists.php.net to get a copy of this message
I wrote the function that is useful for sending emails for example in cyrillic encoding (wondows-1251, koi8-r and so on). It converts every symbol in the string into hexadecimal presentation with "=" symbol as delimiter. For example, the string "Ðåãèñòðàöèîííûé êîä äëÿ" will look like that: =d0=e5=e3=e8=f1=f2=f0=e0=f6=e8=ee=ed=ed=fb=e9=20=ea=ee=e4=20=e4=eb=ff I use it for encoding email subject, but it could be modified for anything else. function hex4email ($string,$charset) { $string=bin2hex ($string); $encoded = chunk_split($string, 2, '='); $encoded=preg_replace ("/=$/","",$encoded); $string="=?$charset?Q?".$encoded."?="; return $string; }; -- http://www.php.net/manual/en/function.bin2hex.php http://master.php.net/manage/user-notes.php?action=edit+17571 http://master.php.net/manage/user-notes.php?action=delete+17571 http://master.php.net/manage/user-notes.php?action=reject+17571

« previous php.notes (#22614) next »