Subversion Repositories php_utils

Compare Revisions

Regard whitespace Rev 51 → Rev 52

/trunk/SecureMailer.class.php
79,7 → 79,8
}
 
public static function utf8Subject($subject) {
return '=?UTF-8?B?'.base64_encode(utf8_encode($subject)).'?=';
$subject = mb_convert_encoding($subject, 'UTF-8');
return '=?UTF-8?B?'.base64_encode($subject).'?=';
}
 
private function _sendMail($recipient, $subject, $message, $add_headers='') {
/trunk/VtsBrowserDownload.class.php
91,7 → 91,8
header('Content-Disposition: '.$disposition.';filename="'.$name_msie.'"');
} else if (strstr($ua, 'FIREFOX')) {
// TODO: Implement "encodeRFC5987ValueChars" described at https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent ?
header('Content-Disposition: '.$disposition.';filename*="UTF-8\'\''.utf8_encode($name).'"');
$name_utf8 = mb_convert_encoding($name, 'UTF-8');
header('Content-Disposition: '.$disposition.';filename*="UTF-8\'\''.$name_utf8.'"');
} else {
// Note: There is possibly a bug in Google Chrome: https://stackoverflow.com/questions/61866508/chrome-ignores-content-disposition-filename
header('Content-Disposition: '.$disposition.';filename="'.$name.'"');
/trunk/misc_functions.inc.php
86,11 → 86,7
}
 
function convert_to_utf8_no_bom($cont) {
if (mb_detect_encoding($cont, "auto", true) != 'UTF-8') {
# $cont = mb_convert_encoding($cont, 'UTF-8', 'Windows-1252');
# $cont = mb_convert_encoding($cont, 'UTF-8', 'auto');
$cont = mb_convert_encoding($cont, 'UTF-8');
}
$cont = vts_utf8_encode($cont);
 
// Remove BOM
$bom = pack('H*','EFBBBF');
98,6 → 94,19
return $cont;
}
 
function vts_utf8_encode($text) {
$enc = mb_detect_encoding($text, null, true);
if ($enc === false) $enc = mb_detect_encoding($text, ['ASCII', 'UTF-8', 'Windows-1252', 'ISO-8859-1'], true);
if ($enc === false) $enc = null;
 
if ($enc === 'UTF-8') return $text;
 
$res = mb_convert_encoding($text, 'UTF-8', $enc);
if ($res === false) $res = iconv('UTF-8', 'UTF-8//IGNORE', $text);
 
return $res;
}
 
function stripHtmlComments($html) {
// https://stackoverflow.com/questions/11337332/how-to-remove-html-comments-in-php
$html = preg_replace("~<!--(?!<!)[^\[>].*?-->~s", "", $html);
/trunk/xml_utils.inc.php
141,7 → 141,7
}
 
function html_named_to_numeric_entities($str) {
if (!mb_detect_encoding($str, 'UTF-8', true)) $str = utf8_encode($str);
$str = mb_convert_encoding($str, 'UTF-8');
return mb_htmlentities(decodeNamedEntities($str));
}