Skip to content

Encoding issues with umlauts #71

@iluuu1994

Description

@iluuu1994

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions