Le lundi 8 octobre 2007, Gael Beaudoin a écrit :
> On Monday 08 October 2007 05:35:42 you wrote:
> > On Sunday 07 October 2007 10:31:01 pm Gael Beaudoin wrote:
> > > Hi !
> > >
> > > I'm trying to fix some annoying stuff in kopete svn trunk and the first
> > > thing is that all accent of groups/contacts are messed up.
> > >
> > > After a little bit of tracking, the problem comes from method QString
> > > MSNSocket::unescape in protocols/msn/MSNSocket.cpp#787 :
> > >
> > >   QString str2 = QUrl::fromPercentEncoding( str.toLatin1() );
> > >
> > > In the 3.5 branch we have :
> > >
> > >   QString str2 = KURL::decode_string( str, 106 );
> > >
> > > So it seems KURL works better here. KDE4 apidoc says about
> > > KUrl::decode_string:
> > >
> > > "Deprecated:
> > > use QUrl::fromPercentEncoding(encodedURL) instead, but note that it
> > > takes a QByteArray and not a QString. Which makes sense since
> > > everything is 7 bit (ascii) when being percent-encoded."
> > >
> > > The problem seems to be that str.toLatin1() mess up non latin1
> > > characters
> > >
> > > : accents are non latin1 character because they are utf8 encoded (in
> > >
> > > utf8, accents are encoded using 2bytes, even if it could use the latin1
> > > version).
> > >
> > > So, humm ... the fix is easy, replace by this in svn trunk :
> > >
> > >   QString str2 = KUrl::decode_string( str );
> > >
> > > Tested, it works like in 3.5 branch.
> > > But this is deprecated and I don't have more idea for now.
> > > Moreover, as msn uses unicode, we souldn't use toLatin1 at all I guess.
> > >
> > > Well, ideas ?
> > >
> > > Gaël Beaudoin (gaboo)
> >
> > QUrl::toPercentEncoding( str.toUtf8() );
>
> Oh ! Indeed, it works. Thanks :)
> But there seems to be some side effects. For example, I get this message
> after a successful login :
>
> "Unhandled MSN error code 911
> Please fill a bug report with a detailed description and if possible the
> last console debug output."
>
> I'll try to see what's the problem.

You need to paste the debug output, but i fear this is caused by "double 
unicode"

Maybe

QString str2 = QString::fromUtf8 ( QUrl::toPercentEncoding( str.toUtf8
() ).toLatin1() );

The problem is that IIRC MSN only encode some of the character (espaces)
Even if the above works, it may be faster to implement our own loop looking 
for %xx.


Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
kopete-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kopete-devel

Reply via email to