summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/functions/functions_rtl.php15
-rw-r--r--includes/functions/functions_utf-8.php3
2 files changed, 10 insertions, 8 deletions
diff --git a/includes/functions/functions_rtl.php b/includes/functions/functions_rtl.php
index 8cb8865b31..9549a4e168 100644
--- a/includes/functions/functions_rtl.php
+++ b/includes/functions/functions_rtl.php
@@ -1263,9 +1263,6 @@ function hasLTRText($text) {
* quotation marks, etc. must be reversed so that the appearance of the RTL text is preserved.
*/
function reverseText($text) {
- $UTF8_numbers=WT_UTF8_DIGITS;
- $UTF8_brackets=WT_UTF8_PARENTHESES;
-
$text = strip_tags(html_entity_decode($text,ENT_COMPAT,'UTF-8'));
$text = str_replace(array('‎', '‏', WT_UTF8_LRM, WT_UTF8_RLM), '', $text);
$textLanguage = utf8_script($text);
@@ -1282,12 +1279,16 @@ function reverseText($text) {
$letter = substr($text, 0, $charLen);
$text = substr($text, $charLen);
- if (in_array($letter, $UTF8_numbers)) $numbers .= $letter; // accumulate numbers in LTR mode
- else {
+ if (strpos(WT_UTF8_DIGITS, $letter)!==false) {
+ $numbers .= $letter; // accumulate numbers in LTR mode
+ } else {
$reversedText = $numbers.$reversedText; // emit any waiting LTR numbers now
$numbers = '';
- if (isset($UTF8_brackets[$letter])) $reversedText = $UTF8_brackets[$letter].$reversedText;
- else $reversedText = $letter.$reversedText;
+ if (strpos(WT_UTF8_PARENTHESES1, $letter)!==false) {
+ $reversedText = substr(WT_UTF8_PARENTHESES2, strpos(WT_UTF8_PARENTHESES1, $letter), strlen($letter)).$reversedText;
+ } else {
+ $reversedText = $letter.$reversedText;
+ }
}
}
diff --git a/includes/functions/functions_utf-8.php b/includes/functions/functions_utf-8.php
index 4d41aecb78..e85a3fdd7e 100644
--- a/includes/functions/functions_utf-8.php
+++ b/includes/functions/functions_utf-8.php
@@ -310,7 +310,8 @@ function utf8_wordwrap($string, $width=75, $sep="\n", $cut=false) {
// This is a list of digits. Note that arabic digits are displayed LTR, even in RTL text
define('WT_UTF8_DIGITS', '0123456789٠١٢٣٤٥٦٧٨٩۰۱۲۳۴۵۶۷۸۹');
// This is a list of parentheses, which need special RTL logic.
-define('WT_UTF8_PARENTHESES', ')(][}{><»«﴾﴿‹›““”‘‘’');
+define('WT_UTF8_PARENTHESES1', ')(][}{><»«﴾﴿‹›“”‘’');
+define('WT_UTF8_PARENTHESES2', '()[]{}<>«»﴿﴾›‹”“’‘');
// This is a list of all reversable character conversions from the UNICODE 5.1 database.
// It excludes ambiguous (dotless i) and mixed-case (Dz) characters.