Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

"codecForName " use this function i can't get anything for GB2312



  • I USE QTextCodec *pCodec = QTextCodec::codecForName("gb2312");
    AND pCodec = NULL

    "availableCodecs " by this function i got 117 .but there is no gb2312 .
    I Run QT soft in linux systerm .
    what 's the problem?


  • Moderators

    @jihong said:

    "availableCodecs " by this function i got 117 .but there is no gb2312 .
    I Run QT soft in linux systerm .
    what 's the problem?

    Your system doesn't have the GB2312 codec.

    Do you have ICU installed?



  • This post is deleted!


  • @JKSH
    Sorry ,I am not understand anything about ICU .what't ICU short for ? Is it a plugin that need install?
    where can i download ICU ? I did't serch anything about ICU in QT website.
    In linux terminal ,use" locale -e " ,we can got Gb2312
    Thank you for your reply.


  • Moderators

    ICU stands for "International Components for Unicode". It is an external library. Qt 5 gets codecs from iCU.

    Search your Linux package manager for "ICU".

    Can you also tell us:

    1. What version of Linux do you have?
    2. How did you install Qt?


  • @JKSH
    I Install ICU already ,but I got the same problem .
    linux version is 2.6.32-358.el6.x84-64
    I compile QT source and change environment variable
    I use the QT version 4.5.3 ..


  • Moderators

    @jihong said:

    I Install ICU already ,but I got the same problem .
    linux version is 2.6.32-358.el6.x84-64
    I compile QT source and change environment variable
    I use the QT version 4.5.3 ..

    Sorry, I thought you were using Qt 5. Qt 4 does not support GB2312. It only supports the codecs listed at http://doc.qt.io/qt-4.8/qtextcodec.html#details

    Can you use GB18030 instead?

    If you want to support GB2312, I think you need to build Qt 5.5.1. Make sure ICU is enabled when you build Qt 5.



  • @JKSH
    I Can't get GB18030 for " availableCodecs " in custorm't cmputer,
    " QTextcode::availableCodecs " this function got totally 117 。
    normally GB18030 is in 118 in our computers.and we got 142 for QTextcode::availableCodecs in our computer .
    Both the computer has the same systerm


  • Moderators

    @jihong said:

    I Can't get GB18030 for " availableCodecs " in custorm't cmputer,

    Try Qt 5.


Log in to reply