I am using a way to compress HTML on fly. Below is the function
function compress_page($buffer) {
$search = array(
'/\>[^\S ]+/s', /*strip whitespaces after tags, except space*/
'/[^\S ]+\</s', /*strip whitespaces before tags, except space*/
'/(\s)+/s', /*shorten multiple whitespace sequences*/
);
$replace = array(
'>',
'<',
'\\1',
);
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
function is working but the problem is, after implement this, germam characters are not showing anymore. They are showing like "�". Can you please help me to find problem. I tried other ways to minify HTML but get same proble.