Skip to content

Optimize Unicode chr/ord #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

ranvis
Copy link
Contributor

@ranvis ranvis commented Feb 21, 2020

Small optimization for unicodeChr() and unicodeOrd().

@shuuryou
Copy link

The maintainer of this project and the author of this PR have probably moved on a long time ago.

For anyone stopping by here, in modern versions of you PHP you can just do:

    public static function unicodeChr($code) {
        return mb_chr($code, 'UCS-2LE');
    }

    public static function unicodeOrd($char) {
       return mb_ord($char, 'UCS-2LE');
    }

Note that in my private patched copy of yetanotherape/diff-match-patch I'm using UTF-8 everywhere instead of UCS-2LE. Without having tested it, I would wager that the mb_* functions will also work when the encoding is UCS-2LE.

@yetanotherape
Copy link
Owner

@shuuryou thanks for pointing to mb_chr/mb_ord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants