Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Impact of Qt on ICU ?
Qt 6.11 is out! See what's new in the release blog

Impact of Qt on ICU ?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved