70) { $result .= "?=\r\n " . $intro; $charcnt = strlen($intro); } $chr = $str[$i]; $code = ord($chr); if($chr=='?' || $chr=='_' || $chr=='=' || $chr<' ' || $chr>'~' ) { $result .= sprintf("=%02X", ord($chr)); $charcnt+=3; } else { $result .= ($chr==' ' ? "_" : $chr); $charcnt++; } } $result .= "?="; return $result; } function rfc2047short($str, $encode) { if(!$str) return ''; return preg_replace_callback('/^([ -~]*)(.*?)([ -~]*)$/', function($m) use ($encode) { return "$m[1]".rfc2047conv("$m[2]",$encode)."$m[3]"; }, $str); } $txt = get($_GET, "txt"); $res = rfc2047short($txt, 'UTF-8'); ?> RFC 2047 implementation

RFC 2047 implementation

All email headers may contain ASCII chars only. Any other chars must be encoded according RFC 2047. Here is a simple implementation of the specification for PHP.

Source code is avalable.

License: public domain - you may use the code in any way but the author (me) geves you no warranty.

Text:
Origin: []
Result: []