Skip to content

Not many tests for multibyte Unicode characters #66

Description

@onebytegone

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("🐨"));'
��

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions