Opened 6 years ago

Closed 6 years ago

#1484429 closed Bugs (fixed)

UTF-8 bug

Reported by: sergyn Owned by: thomasb
Priority: 5 Milestone: 0.1-rc2
Component: Client Scripts Version: 0.1-rc1
Severity: normal Keywords: localization
Cc:

Description

In message list, russian letter Р displayed as ? in Browser when navigation from page to page. Seems AJAX make something wrong?

Change History (7)

comment:1 Changed 6 years ago by till

  • Component changed from Core functionality to Client
  • Keywords localization added

Can you provide a patch for your messages file? I sure cannot. :)

comment:2 Changed 6 years ago by till

  • Milestone set to 0.1-rc2

comment:3 Changed 6 years ago by thomasb

  • Owner set to thomasb
  • Status changed from new to assigned

Remove the following lines from rep_specialchars_output() should help:

if ($enctype!='html')
  $str = str_replace(chr(160), ' ', $str);

Suggested by Yoshikazu Tsuji

comment:4 Changed 6 years ago by thomasb

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in [74ae8849]

comment:5 Changed 6 years ago by yskzt@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

I searched web sites.

So, how about this?

--- main.inc_   2007-09-03 16:10:32.000000000 +0900 (rev 774)
+++ main.inc    2007-09-12 01:05:31.000000000 +0900 (changed)
@@ -1103,6 +1103,17 @@
   return $str;
   }

+function mb_str_replace($search_str, $replace_str, $str)
+  {
+  $current_pos = 0;
+  while (($found_pos = mb_strpos($str, $search_str, $current_pos)) !==
false)
+    {
+    $str = mb_substr($str, 0, $found_pos).$replace_str.mb_substr($str,
$found_pos + mb_strlen($search_str));
+    $current_pos = $found_pos + strlen($replace_str);
+    }
+
+  return $str;
+  }

 /**
  * Replacing specials characters to a specific encoding type
@@ -1123,7 +1134,12 @@

   // convert nbsps back to normal spaces if not html
   if ($enctype!='html')
-    $str = str_replace(chr(160), ' ', $str);
+    {
+    if ($OUTPUT->get_charset()=='UTF-8')
+      $str = mb_str_replace(chr(194).chr(160), ' ', $str);
+    else
+      $str = str_replace(chr(160), ' ', $str);
+    }

   // encode for plaintext
   if ($enctype=='text')

comment:6 Changed 6 years ago by yskzt@…

I noticed that the mb_str_replace function can be replace to mb_ereg_replace function. mb_str_replace fuction was the function I added and bad naming.

--- main.inc_   2007-09-03 16:10:32.000000000 +0900 (rev 774)
+++ main.inc    2007-09-12 01:05:31.000000000 +0900 (changed)
@@ -1103,6 +1103,17 @@
   return $str;
   }

 /**
  * Replacing specials characters to a specific encoding type
@@ -1123,7 +1134,12 @@

   // convert nbsps back to normal spaces if not html
   if ($enctype!='html')
-    $str = str_replace(chr(160), ' ', $str);
+    {
+    if ($OUTPUT->get_charset()=='UTF-8')
+      $str = mb_ereg_replace(chr(194).chr(160), ' ', $str);
+    else
+      $str = str_replace(chr(160), ' ', $str);
+    }

   // encode for plaintext
   if ($enctype=='text')

comment:7 Changed 6 years ago by thomasb

  • Resolution set to fixed
  • Status changed from reopened to closed

We simply leave nbsps untouched as any other character. There's no need for a complicated fix like this.

Note: See TracTickets for help on using tickets.