From 7232001d9fbc3e76671e3fb50fd3d8cd4b102eab Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sun, 15 Nov 2020 08:59:43 +0100 Subject: [PATCH] Regex with better distinction between LTR and RTL characters Co-authored-by: MoonE --- src/ol/render/canvas/Executor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ol/render/canvas/Executor.js b/src/ol/render/canvas/Executor.js index 1ec4c94eb0..86bf232fd0 100644 --- a/src/ol/render/canvas/Executor.js +++ b/src/ol/render/canvas/Executor.js @@ -75,7 +75,17 @@ function getDeclutterBox(replayImageOrLabelArgs) { return replayImageOrLabelArgs[3].declutterBox; } -const rtlRegEx = /[\u0591-\u07FF]/; +const rtlRegEx = new RegExp( + /* eslint-disable prettier/prettier */ + '[' + + String.fromCharCode(0x00591) + '-' + String.fromCharCode(0x008ff) + + String.fromCharCode(0x0fb1d) + '-' + String.fromCharCode(0x0fdff) + + String.fromCharCode(0x0fe70) + '-' + String.fromCharCode(0x0fefc) + + String.fromCharCode(0x10800) + '-' + String.fromCharCode(0x10fff) + + String.fromCharCode(0x1e800) + '-' + String.fromCharCode(0x1efff) + + ']' + /* eslint-enable prettier/prettier */ +); /** * @param {string} text Text.