Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.7.0

Bug #18589 Multibyte support bug.
Submitted: 2011-06-06 07:11 UTC
From: ariela Assigned: farell
Status: Closed Package: Net_Growl (version 2.2.2)
PHP Version: 5.3.6 OS: Windows
Roadmaps: 2.3.0    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 37 - 21 = ?

 
 [2011-06-06 07:11 UTC] ariela (Takeshi Kawamoto)
Description: ------------ sendNotify method can not send multibyte(Japanese) message. character set encode error for utf8_encode. please use "mb_convert_encoding($value, 'UTF-8', 'auto')" (detect order encoding to UTF-8 encoding. set encoding detect order by "mb_detect_order") Patches ========================= Net_Growl_Gntp --- D:/develop/xampp/php/PEAR/Net/Growl/Gntp.php.orig Mon Jun 06 10:56:26 2011 +++ D:/develop/xampp/php/PEAR/Net/Growl/Gntp.php Mon Jun 06 11:07:53 2011 @@ -99,7 +99,7 @@ // Application-Name: <string> // Required - The name of the application that is registering $data = "Application-Name: " - . utf8_encode($this->getApplication()- >getGrowlName()) + . mb_convert_encoding($this->getApplication()- >getGrowlName(), 'UTF-8', 'auto') . "\r\n"; // Application-Icon: <url> | <uniqueid> @@ -131,7 +131,7 @@ // Notification-Name: <string> // Required - The name (type) of the notification being registered - $data .= "Notification-Name: " . utf8_encode($name) . "\r\n"; + $data .= "Notification-Name: " . mb_convert_encoding($name, 'UTF-8', 'auto') . "\r\n"; // Notification-Display-Name: <string> // Optional - The name of the notification that is displayed to the user @@ -215,10 +215,10 @@ */ public function sendNotify($name, $title, $description, $options) { - $appName = utf8_encode($this->getApplication()- >getGrowlName()); - $name = utf8_encode($name); - $title = utf8_encode($title); - $description = utf8_encode($description); + $appName = mb_convert_encoding($this- >getApplication()->getGrowlName(), 'UTF-8', 'auto'); + $name = mb_convert_encoding($name, 'UTF-8', 'auto'); + $title = mb_convert_encoding($title, 'UTF-8', 'auto'); + $description = mb_convert_encoding($description, 'UTF-8', 'auto'); $priority = isset($options['priority']) ? $options['priority'] : self::PRIORITY_NORMAL; $icon = isset($options['icon']) ? $options['icon'] : ''; @@ -389,7 +389,7 @@ $cipherText = $data; } else { if (!isset($keys)) { - $password = utf8_encode($password); + $password = mb_convert_encoding($password, 'UTF-8', 'auto'); $keys = $this->_genKey($password); } list($hash, $key) = $keys; Net_Growl_Udp --- D:/develop/xampp/php/PEAR/Net/Growl/Udp.php.orig Fri Jun 03 19:31:45 2011 +++ D:/develop/xampp/php/PEAR/Net/Growl/Udp.php Mon Jun 06 11:07:52 2011 @@ -84,7 +84,7 @@ */ public function sendRegister() { - $appName = utf8_encode($this->getApplication()- >getGrowlName()); + $appName = mb_convert_encoding($this- >getApplication()->getGrowlName(), 'UTF-8', 'auto'); $password = $this->getApplication()- >getGrowlPassword(); $nameEnc = $defaultEnc = ''; $nameCnt = $defaultCnt = 0; @@ -96,7 +96,7 @@ $defaultCnt++; } - $name = utf8_encode($name); + $name = mb_convert_encoding($name, 'UTF-8', 'auto'); $nameEnc .= pack('n', mb_strlen($name)).$name; $nameCnt++; } @@ -134,11 +134,11 @@ */ public function sendNotify($name, $title, $description, $options) { - $appName = utf8_encode($this->getApplication()- >getGrowlName()); + $appName = mb_convert_encoding($this- >getApplication()->getGrowlName(), 'UTF-8', 'auto'); $password = $this->getApplication()- >getGrowlPassword(); - $name = utf8_encode($name); - $title = utf8_encode($title); - $description = utf8_encode($description); + $name = mb_convert_encoding($name, 'UTF-8', 'auto'); + $title = mb_convert_encoding($title, 'UTF-8', 'auto'); + $description = mb_convert_encoding($description, 'UTF-8', 'auto'); $priority = isset($options['priority']) ? $options['priority'] : Net_Growl::PRIORITY_NORMAL; Test script: --------------- $growl->notify('test', "???(Japanese)", "????????(Japanese message)", array()); Expected result: ---------------- Notification-Name: test Notification-Title: æ?¥æ?¬èª?(Japanese) Notification-Text: æ?¥æ?¬èª?ã?¡ã??ã?»ã?¼ã?¸(Japanese message)

Comments

 [2011-06-06 07:16 UTC] ariela (Takeshi Kawamoto)
 [2011-06-06 07:17 UTC] ariela (Takeshi Kawamoto)
 [2011-06-06 16:15 UTC] farell (Laurent Laville)
-Status: Open +Status: Feedback
Hello Takeshi, I've some problem to test your patchs in real condition. Could you provide a test protocol (how to set/configure) a php script / ini config (probably) to display what you're expected. Thanks in advance Laurent
 [2011-06-07 06:29 UTC] ariela (Takeshi Kawamoto)
Hello Laurent multibyte test script and test server's configures, upload to my server. please download from http://transrain.net/share/net_growl_multibyte_test.tar.gz * UTF-8 version append test code for Chinese and Korean. Thanks in advance.
 [2011-06-07 23:12 UTC] farell (Laurent Laville)
Thanks Takeshi, My suprise came from the results I got from my growl display. Have a look on screenshots I shared at : http://www.laurent-laville.org/pear/pepr/Net_Growl/ Is it what you get yourself, or is it just me ? My platform is Windows XP / PHP 5.3.5
 [2011-06-08 05:48 UTC] ariela (Takeshi Kawamoto)
Hello Laurent I've seen your screenshot, but not expected result. (not installed asian font on other than asian platform...?) take screenshot on My platform (Windows XP for japanese and PHP 5.3.5). I shared at: http://transrain.net/share/ test01*.png - test08*.png
 [2011-06-08 08:00 UTC] ariela (Takeshi Kawamoto)
 [2011-06-08 08:00 UTC] ariela (Takeshi Kawamoto)
 [2011-06-08 08:00 UTC] ariela (Takeshi Kawamoto)
 [2011-06-08 08:50 UTC] ariela (Takeshi Kawamoto)
Attach new patch. I find other multibyte bug. * strlen / mb_strlen (mb_)strlen is measured for character length. multibyte character is 1character = 2?6byte. new patch supported get string byte length method for Net/Growl.php *strlen?substr function overloaded to mbstring extension. http://www.php.net/manual/en/mbstring.overload.php
 [2011-06-11 14:43 UTC] farell (Laurent Laville)
-Status: Feedback +Status: Assigned -Assigned To: +Assigned To: farell
Hello Takeshi Thanks for these new patches. I confirm, now I've installed asian fonts, that all goes right even with Callbacks and Encryption features. Will be include in incoming version 2.3.0 I've just changed names of your protected methods suffixed by an underscore that is forbidden in PEAR coding standard. Laurent
 [2011-06-11 15:30 UTC] farell (Laurent Laville)
-Status: Assigned +Status: Closed
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/