Skip to content
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

Current implementation is differs from original C implementation on emojis #4

Open
skryukov opened this issue Jun 29, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@skryukov
Copy link

Hey, I noticed that current implementation is differs from original C implementation on emojis. This might be a problem for multilingual systems.

Example with the string from Readme:

#include <stdio.h>

unsigned long hash(unsigned char *str) {
        unsigned long hash = 5381;
        int c;
        while ((c = *str++))
                hash = ((hash << 5) + hash) ^ c;
        return hash & 0xFFFFFFFF;
}

int main() {
        unsigned char myString [] = "🦄🌈";

        printf("hash %ld\n", hash(myString));
        return 0;
}

// => hash 1642026147
@sindresorhus
Copy link
Owner

This is a limitation in integers in JS. We need to move to BigInt. Example: https://github.com/sindresorhus/fnv1a

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants