Skip to content

Erron in PHP7 #6

@tarastalian

Description

@tarastalian

There is an error in PHP 7. The lib it's always returning 'Malformatted' for every character, instead of the alphabet itself.
There is a problem in TextLanguageDetect, in the way the unicode compares to the hex of the blocks. It war working in PHP 5 but not in PHP 7.

        // your average binary search algorithm
        while ($low <= $high) {
            $mid = floor(($low + $high) / 2);

            if ($unicode < $blocks[$mid][0]) {
                // if it's lower than the lower bound
                $high = $mid - 1;

            } elseif ($unicode > $blocks[$mid][1]) {
                // if it's higher than the upper bound
                $low = $mid + 1;

            } else {
                // found it
                return $blocks[$mid];
            }
        }

I'd changed wiht this one to fix it

        // your average binary search algorithm
        while ($low <= $high) {
            $mid = floor(($low + $high) / 2);

            if ($unicode < hexdec($blocks[$mid][0])) {
                // if it's lower than the lower bound
                $high = $mid - 1;

            } elseif ($unicode > hexdec($blocks[$mid][1])) {
                // if it's higher than the upper bound
                $low = $mid + 1;

            } else {
                // found it
                return $blocks[$mid];
            }
        }

How do i make this changes accesible to everybody?

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