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

Not many tests for multibyte Unicode characters #66

Open
onebytegone opened this issue Apr 28, 2017 · 0 comments
Open

Not many tests for multibyte Unicode characters #66

onebytegone opened this issue Apr 28, 2017 · 0 comments

Comments

@onebytegone
Copy link

It's great to find a library like this, string manipulation in JS often leaves much to be desired. However, the limited scope of testing with strings containing multibyte Unicode characters is concerning. Multibyte characters often create quite a few headaches. (These's a nice writeup about the challenges here)

There are already a few tests that check the processing of multibyte characters, e.g. decencode.test.js. Having more tests to ensue safe handling of strings containing multibyte characters would be a wonderful addition!

Understandably, it might not be possible for all functions to safely support multibyte characters. Perhaps this could be documented as a limitation on these functions?

Simple example of current behavior:

$ pwd
~/strman
$ node -v
v7.9.0

$ node -e 'console.log("A".length);'
1
$ node -e 'console.log("漢".length);'
1
$ node -e 'console.log("\u200B".length);'
1
$ node -e 'console.log("🐨".length);'
2

$ node -e 'console.log(require("./lib/strman.js").last("A"));'
A
$ node -e 'console.log(require("./lib/strman.js").last("漢"));'
漢
$ node -e 'console.log(require("./lib/strman.js").last("🐨"));'
🐨

$ node -e 'console.log(require("./lib/strman.js").reverse("A"));'
A
$ node -e 'console.log(require("./lib/strman.js").reverse("漢"));'
漢
$ node -e 'console.log(require("./lib/strman.js").reverse("🐨"));'
��
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

No branches or pull requests

1 participant