function _b_($str) { return utf8_decode(dgettext('banana', utf8_encode($str))); }
+function to_entities($str) {
+ require_once 'banana/utf8.php';
+ return utf8entities(htmlentities($str, ENT_NOQUOTES, 'UTF-8'));
+}
+
+function is_utf8($s) { return iconv('utf-8', 'utf-8', $s) == $s; }
+
/********************************************************************************
* HEADER STUFF
*/
return preg_replace('/=\?([^?]*)\?([BQ])\?([^?]*)\?=/e', '_headerdecode("\1", "\2", "\3")', $val);
}
+function headerEncode($value, $trim = 0) {
+ if ($trim) {
+ if (strlen($value) > $trim) {
+ $value = substr($value, 0, $trim) . "[...]";
+ }
+ }
+ return "=?UTF-8?B?".base64_encode($value)."?=";
+}
+
function header_translate($hdr) {
switch ($hdr) {
case 'from': return _b_('De');
}
function formatbody($_text) {
- $res = "\n\n" . htmlentities(wrap($_text, ""))."\n\n";
+ $res = "\n\n" . to_entities(wrap($_text, ""))."\n\n";
$res = preg_replace("/(<|>|")/", " \\1 ", $res);
$res = preg_replace('/(["\[])?((https?|ftp|news):\/\/[a-z@0-9.~%$£µ&i#\-+=_\/\?]*)(["\]])?/i', "\\1<a href=\"\\2\">\\2</a>\\4", $res);
$res = preg_replace("/ (<|>|") /", "\\1", $res);