Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Communications Framework (ECF) » MSN encoding Bug
MSN encoding Bug [message #619793] Tue, 13 November 2007 07:15 Go to next message
Eclipse UserFriend
Originally posted by: spark.ma.gmail.com

enviroment: OS(XP Sp2), locale(chinese_china)

if contracts nike name or personal message contains chinese character, it will be garbage. This is caused by
when new string the default encoding is OS setting (for me, it is GB18030), but MSN usually uses UTF-8.
It can be fixed by following code (hard code).

Index: src/org/eclipse/ecf/protocol/msn/NotificationSession.java
============================================================ =======
RCS file:
/cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Notification Session.java,v
retrieving revision 1.4
diff -r1.4 NotificationSession.java
127c127
< BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream()));
---
> BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(), "UTF-8"));


Index: Session.java
============================================================ =======
RCS file:
/cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java ,v
retrieving revision 1.2
diff -r1.2 Session.java
148c148
< return new String(buffer, 0, read).trim();
---
> return new String(buffer, 0, read, "UTF-8").trim();
276c276
<
---
>


Good luck!
Re: MSN encoding Bug [message #619797 is a reply to message #619793] Wed, 14 November 2007 20:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: remy.suen.gmail.com

Hi,

We actually have a bug open for this. Would you mind attaching your patch
there as an attachment?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=188583

Regards,
Rem

On Tue, 13 Nov 2007 15:15:18 +0800, spark.ma wrote:

> enviroment: OS(XP Sp2), locale(chinese_china)
>
> if contracts nike name or personal message contains chinese character, it will be garbage. This is caused by
> when new string the default encoding is OS setting (for me, it is GB18030), but MSN usually uses UTF-8.
> It can be fixed by following code (hard code).
>
> Index: src/org/eclipse/ecf/protocol/msn/NotificationSession.java
> ============================================================ =======
> RCS file:
> /cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Notification Session.java,v
> retrieving revision 1.4
> diff -r1.4 NotificationSession.java
> 127c127
> < BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream()));
> ---
> > BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(), "UTF-8"));
>
>
> Index: Session.java
> ============================================================ =======
> RCS file:
> /cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java ,v
> retrieving revision 1.2
> diff -r1.2 Session.java
> 148c148
> < return new String(buffer, 0, read).trim();
> ---
> > return new String(buffer, 0, read, "UTF-8").trim();
> 276c276
> <
> ---
> >
>
>
> Good luck!
Re: MSN encoding Bug [message #619798 is a reply to message #619797] Thu, 15 November 2007 03:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: spark.ma.gmail.com

Hi,

No problem.

Thanks

Remy Chi Jian Suen wrote:
> Hi,
>
> We actually have a bug open for this. Would you mind attaching your patch
> there as an attachment?
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=188583
>
> Regards,
> Rem
>
> On Tue, 13 Nov 2007 15:15:18 +0800, spark.ma wrote:
>
>> enviroment: OS(XP Sp2), locale(chinese_china)
>>
>> if contracts nike name or personal message contains chinese character, it will be garbage. This is caused by
>> when new string the default encoding is OS setting (for me, it is GB18030), but MSN usually uses UTF-8.
>> It can be fixed by following code (hard code).
>>
>> Index: src/org/eclipse/ecf/protocol/msn/NotificationSession.java
>> ============================================================ =======
>> RCS file:
>> /cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Notification Session.java,v
>> retrieving revision 1.4
>> diff -r1.4 NotificationSession.java
>> 127c127
>> < BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream()));
>> ---
>> > BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(), "UTF-8"));
>>
>>
>> Index: Session.java
>> ============================================================ =======
>> RCS file:
>> /cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java ,v
>> retrieving revision 1.2
>> diff -r1.2 Session.java
>> 148c148
>> < return new String(buffer, 0, read).trim();
>> ---
>> > return new String(buffer, 0, read, "UTF-8").trim();
>> 276c276
>> <
>> ---
>> >
>>
>>
>> Good luck!
>
Re: MSN encoding Bug [message #619799 is a reply to message #619793] Thu, 15 November 2007 05:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: spark.ma.gmail.com

I've add more code for MSN which fix the following problem.

1) cann't send DBCS character(such Chinese), which is caused by incorrect message length.
2) can't receive DBCS character, it is caused by incorrect length too.
3) if contract is off-line (blocked), if open message input, it cause infinite loop.

I think ECP is a great works, it very useful for ME!
============================================================ ========================================================

Index: src/org/eclipse/ecf/protocol/msn/NotificationSession.java
============================================================ =======
RCS file:
/cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Notification Session.java,v
retrieving revision 1.4
diff -r1.4 NotificationSession.java
127c127
< BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream()));
---
> BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(), "UTF-8"));
Index: src/org/eclipse/ecf/protocol/msn/ChatSession.java
============================================================ =======
RCS file:
/cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/ChatSession. java,v
retrieving revision 1.4
diff -r1.4 ChatSession.java
144c144,145
< while (!joined);
---
> if (!joined)
> ;//FIXME why need this?
299,300c300,301
< final int text = count - (split[0].length() + 4);
< fireMessageReceivedEvent(contact, split[1].substring(0, text));
---
> final int text = count - (split[0].getBytes("UTF-8").length + 4); //$NON-NLS-1$
> fireMessageReceivedEvent(contact, new String(split[1].getBytes("UTF-8"), 0, text, "UTF-8")); //$NON-NLS-1$
//$NON-NLS-2$
339c340
< write("MSG", "N " + message.length() + "\r\n" + message, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
---
> write("MSG", "N " + message.getBytes("UTF-8").length + "\r\n" + message, false); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
Index: src/org/eclipse/ecf/protocol/msn/Session.java
============================================================ =======
RCS file:
/cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java ,v
retrieving revision 1.2
diff -r1.2 Session.java
148c148
< return new String(buffer, 0, read).trim();
---
> return new String(buffer, 0, read, "UTF-8").trim(); //$NON-NLS-1$
167c167
< byte[] bytes = newline ? (input + "\r\n").getBytes() : input.getBytes(); //$NON-NLS-1$
---
> byte[] bytes = newline ? (input + "\r\n").getBytes("UTF-8") : input.getBytes("UTF-8"); //$NON-NLS-1$


> enviroment: OS(XP Sp2), locale(chinese_china)
>
> if contracts nike name or personal message contains chinese character,
> it will be garbage. This is caused by
> when new string the default encoding is OS setting (for me, it is
> GB18030), but MSN usually uses UTF-8.
> It can be fixed by following code (hard code).
>
> Index: src/org/eclipse/ecf/protocol/msn/NotificationSession.java
> ============================================================ =======
> RCS file:
> /cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Notification Session.java,v
>
> retrieving revision 1.4
> diff -r1.4 NotificationSession.java
> 127c127
> < BufferedReader reader = new BufferedReader(new
> InputStreamReader(getInputStream()));
> ---
> > BufferedReader reader = new BufferedReader(new
> InputStreamReader(getInputStream(), "UTF-8"));
>
>
> Index: Session.java
> ============================================================ =======
> RCS file:
> /cvsroot/technology/org.eclipse.ecf/providers/org.eclipse.ec f.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java ,v
>
> retrieving revision 1.2
> diff -r1.2 Session.java
> 148c148
> < return new String(buffer, 0, read).trim();
> ---
> > return new String(buffer, 0, read, "UTF-8").trim();
> 276c276
> <
> ---
> >
>
>
> Good luck!
>
Re: MSN encoding Bug [message #619800 is a reply to message #619799] Sat, 17 November 2007 01:58 Go to previous message
Eclipse UserFriend
Originally posted by: remy.suen.gmail.com

Since the newsgroup is covered by the Eclipse terms of use and is
therefore under the EPL, I have committed the suggested changes to CVS
HEAD and have closed bug 188583. Thank you for your assistance.

Regards,
Rem
Previous Topic:XMPP extension and IQ providers
Next Topic:Howo attend ECF Team Meetings - Conference Calls
Goto Forum:
  


Current Time: Fri Apr 26 21:25:25 GMT 2024

Powered by FUDForum. Page generated in 0.03502 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top