Impact of Qt on ICU ?



  • Hello,

    I'm using both QtCore and ICU and as soon in my code I declare a QCoreApplication, ICU locale functions no longer works correctly.

    @
    #include <iostream>
    #include <unicode/numfmt.h>
    #include <QCoreApplication>

    void test_icu(const Formattable& fmtbl)
    {
    Locale locale("en");
    UErrorCode status = U_ZERO_ERROR;
    NumberFormat* fmt = NumberFormat::createInstance(locale, status);

        if (U_FAILURE(status))
        {
                std::cerr << "NumberFormat::createInstance failed with code " << status << std::endl;
        }
        else
        {
                UnicodeString text;
                fmt->format(fmtbl, text, status);
    
                if (U_FAILURE(status))
                {
                        std::cerr << "NumberFormat::format failed with code " << status << std::endl;
                }
                else
                {
                        std::string result;
                        text.toUTF8String(result);
                        std::cout << "Result = " << result << std::endl;
                }
        }
    

    }

    void test_icu()
    {
    test_icu(Formattable(123));
    test_icu(Formattable(123.456));
    }

    int main(int argc, char** argv)
    {
    test_icu();
    QCoreApplication app(argc, argv);
    test_icu();
    return 0;
    }
    @

    The output is :

    @
    Result = 123
    Result = 123.456
    Result = 123
    Result = NaN
    @

    ICU failed to format float values after QCoreApplication initialization.

    I'm using Qt 4.7.4, ICU 4.8 on Debian wheezy (amd64).

    Does Qt change the system locale or the cpu floating precision ?

    Thank you in advance.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.