[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Hi, some comments about encoding detection (KEncodingDetector)
From:       "Wang Hoi" <zealot.hoi () gmail ! com>
Date:       2008-08-04 8:47:49
Message-ID: 2c13fc000808040147m2749dd53k7ffa4786291dc722 () mail ! gmail ! com
[Download RAW message or body]


a modified patch, introduce KEncodingProber  (KEncodingDetector2 is a bad name)
with a clean and more powerful interface:
class KDECORE_EXPORT KEncodingProber
{
public:
    enum ProberState {
        FoundIt, // sure
        NotMe,   // sure not
        Probing  //initial State or not sure
    };
    enum ProberType {
        Universal,
        Arabic,
        ..........
        Unicode,
        WesternEuropean
    };
    KEncodingProber(ProberType proberType=Universal);
    ~KEncodingProber();

    void reset();
    ProberState feed(const QByteArray &data);
    ProberState feed(const char* data, int len);
    ProberState getState() const;
    const char* getEncoding() const;
    float getConfidence() const;          //  0.0 ~ 0.99
private:
    KEncodingProberPrivate* const d;
};

user can feed data to it continously, until ProberState change from
Probing to FoundIt or NotMe, when ProberState==Probing, user can also
call getConfidence() etc.. to get the most confident encoding it
guessed from feeded data.
it's used to *guess* the encoding of raw text, not able to get the
encoding directly from Html/Xml tags ( such as <?xml encoding="xxx" ?>
).

["encodingDetection.patch.tar.bz2" (application/x-bzip2)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic