Non-ASCII character support#45736
Conversation
|
test const isLiteralSymbol = (char) => {
const code = char.charCodeAt(0);
if (code > 127) {
return true;
}
if (char >= '0' && char <= 9) {
return false;
}
if (code === 35) {
return false;
}
return true;
}output isLiteralSymbol('أهلا')
true |
|
@anonrig I applied the changes, thank you very much for the review 🚀 |
|
@manekinekko Can you review this? |
MoLow
left a comment
There was a problem hiding this comment.
the change LGTM, but this seems to break quite a few tests
| assert.strictEqual(isLiteralSymbol('#'), false); | ||
| assert.strictEqual(isLiteralSymbol('أ'), true); | ||
| assert.strictEqual(isLiteralSymbol('ت'), true); | ||
| assert.strictEqual(isLiteralSymbol('ث'), true); |
There was a problem hiding this comment.
Could you:
- group these into 2 groups: literals (
true) and non-literals (false)? - add more samples of non-Latin characters? you can cherry-pick from this list here.
There was a problem hiding this comment.
@manekinekko thank you so much i will fly here 🚀
There was a problem hiding this comment.
@manekinekko would that be healthy
{
const literals = ['A', 'a', '-', '+', 'أ', 'ت', 'ث', '讲', '演', '講'];
const nonLiterals = ['0', '#', '\\', '+', '-'];
literals.forEach((literal) => {
assert.strictEqual(isLiteralSymbol(literal), true);
});
nonLiterals.forEach((nonLiteral) => {
assert.strictEqual(isLiteralSymbol(nonLiteral), false);
});
}|
I'm so sorry I triggered you all to review, sorry for the extra notifications :/ |
|
@manekinekko I sent the edits thank you very much |
There was a problem hiding this comment.
Should we really accept zero width characters as acceptable input? I would skip all of them. We also already have a function to check for these:
node/lib/internal/util/inspect.js
Lines 2388 to 2398 in ab064d1
|
I didn't accept zero-width characters @BridgeAR i will update the code like this if (typeof char !== 'string' || util.inspect.isZeroWidthCodePoint(char)) {
return false;
}can I do it like this? |
|
@mertcanaltin I think that would be ok. |
78c70a1 to
4697163
Compare
e05f17f to
eeb6f02
Compare
|
CC @nodejs/test_runner @manekinekko additional reviews will be appreciated |
|
@anonrig can you please dismiss your review/approve? |
|
Landed in 3c6547f |
|
🎉 |
PR-URL: nodejs#45736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: #45736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: #45736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: nodejs#45736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: nodejs#45736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
PR-URL: nodejs#45736 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Fixes #45706
Fixes #46508