private static function sanitise($output)
{
$regex_encoding = mb_regex_encoding();
mb_regex_encoding('UTF-8');
$output = \mb_ereg_replace_callback('[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\x80-\\x9F]', function ($e) {
return '\\' . bin2hex($e[0]);
}, $output);
if ($output === false) {
throw new Exception\ErrorException('PCRE error ocurred while stripping out non-printable characters.');
# var_dump( array_flip(get_defined_constants(true)['pcre'])[preg_last_error()] );
}
mb_regex_encoding($regex_encoding);
return $output;
}