From kopete-devel Fri Jan 23 20:13:31 2004 From: Jason Keirstead Date: Fri, 23 Jan 2004 20:13:31 +0000 To: kopete-devel Subject: Re: [Kopete-devel] [Bug 72917] UTF8 and other cause XML parsing Message-Id: <200401231613.31324.jason () keirstead ! org> X-MARC-Message: https://marc.info/?l=kopete-devel&m=107488884317681 On January 23, 2004 2:48 pm, Thiago Macieira wrote: > Hmm... I don't like this block of code. You're decoding character by > character in UTF-8, which the decoder can't cope with, because you'd be > passing each character in a multi-byte sequence separately. Actually, I > can't find a toUnicode(QChar) function anywhere... > > KStringHandler::isUtf8 is preferrable, except it's marked @since 3.2. > Maybe Kopete should copy that function into its own library then. isUTF8() is fine for checking, but it's useless for taking a string and making it displayable in unicode even if it isn't. The point of this code block is not to determine if a string is UTF.. we pretty much *know* it isn't. It's purpose is to take a non-UTF string for which the codec is totally unknown and make it displayable as UTF, by replacing undecodable characters with ? I had assumed that QChar took care of the doubel byte stuff for me. If it doesn't then I don't know how we can do this. > - if it isn't given, try to the user's locale codec. If that fails, try Why bother with the locale codec? What does my locale have to do with the sender's? > UTF-8 > - if any other fail, decode as Latin1 > - finally, clean up U+0000 to U+001F (excepting, maybe, newlines, etc.) > (note: no locale nor UTF-8 if preferred is given) UTF-8 should be last, because latin1 will indicate failure if it's not latin1. UTF is the only codec in QT that *always* decodes. So we shoudl try that last, then clean it up. Also, hardly any messages are in UTF, so it''s more efficient to have this as the last fallback. -- There's no place like 127.0.0.1 http://www.keirstead.org _______________________________________________ Kopete-devel mailing list Kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel