summaryrefslogtreecommitdiff
path: root/ext/bg/js/translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-10 19:24:24 -0400
committerGitHub <noreply@github.com>2020-03-10 19:24:24 -0400
commitf7bbcb6df403ca565b6dcf3ab468967f830b527d (patch)
treea466132d1e0d69a8e91a0cd52414402778d3eaa6 /ext/bg/js/translator.js
parent36c55f0b17e7c2697543edc38e444d01da4f4a5c (diff)
parent72219ba3530f9da02d3ec1d704baac6f88863682 (diff)
Merge pull request #408 from toasted-nutbread/use-code-point
Replace charCodeAt and fromCharCode with codePointAt and fromCodePoint
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r--ext/bg/js/translator.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 781eb968..c01a7124 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -20,7 +20,7 @@
dictTermsMergeBySequence, dictTagBuildSource, dictTermsMergeByGloss, dictTermsSort, dictTagsSort
dictEnabledSet, dictTermsGroup, dictTermsCompressTags, dictTermsUndupe, dictTagSanitize
jpDistributeFurigana, jpConvertHalfWidthKanaToFullWidth, jpConvertNumericTofullWidth
-jpConvertAlphabeticToKana, jpHiraganaToKatakana, jpKatakanaToHiragana, jpIsCharCodeJapanese
+jpConvertAlphabeticToKana, jpHiraganaToKatakana, jpKatakanaToHiragana, jpIsCodePointJapanese
Database, Deinflector*/
class Translator {
@@ -621,13 +621,14 @@ class Translator {
static getSearchableText(text, options) {
if (!options.scanning.alphanumeric) {
- const ii = text.length;
- for (let i = 0; i < ii; ++i) {
- if (!jpIsCharCodeJapanese(text.charCodeAt(i))) {
- text = text.substring(0, i);
+ let newText = '';
+ for (const c of text) {
+ if (!jpIsCodePointJapanese(c.codePointAt(0))) {
break;
}
+ newText += c;
}
+ text = newText;
}
return text;