caxy/php-htmldiff

Encoding issues with umlauts

iluuu1994 opened this issue · 0 comments

I'm not sure if this repo is still maintained but I'd really appreciate some help. I'm having some encoding issues with umlauts and I cannot for the life of me figure out how to fix this. This is the code I'm running:

$oldValue = 'Änderung';
$newValue = 'Test Änderung';

var_dump($oldValue);
var_dump(mb_detect_encoding($oldValue));
var_dump($newValue);
var_dump(mb_detect_encoding($newValue));

$htmlDiff = new HtmlDiff($oldValue, $newValue);
$result = $htmlDiff->build();

var_dump($result);
var_dump(mb_detect_encoding($result));

//> string(9) "Änderung"
//> string(5) "UTF-8"
//> string(14) "Test Änderung"
//> string(5) "UTF-8"
//> string(74) "test� Test � nderung"
//> string(5) "UTF-8"

For some reason HtmlDiff breaks the encoding. What confuses me is that the example works perfectly on the http://php-htmldiff.caxy.com/ website. Is this not supported or am I doing something wrong?