Edit report at http://pear.php.net/bugs/bug.php?id=18588&edit=1
ID: 18588
Updated by: [email protected]
Reported By: yuki at transrain dot net
Summary: Multibyte support bug.
-Status: Open
+Status: Duplicate
Type: Bug
Package: Net_Growl
Operating System: Windows
Package Version: 2.2.2
PHP Version: 5.3.6
Roadmap Versions:
New Comment:
-Status: Open
+Status: Duplicate
Previous Comments:
------------------------------------------------------------------------
[2011-06-06 03:10:23] ariela
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)
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=18588&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.