Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-9451

QLocale::system().name() always returns "C"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • Some future release
    • 4.6.2
    • Core: Locales (i18n)
    • None

    Description

      Below is the example program and it's results:

      {vl}[vl@qtbug]$ ls
      qt_app.cpp
      {vl}[vl@qtbug]$ cat qt_app.cpp 
      #include <QDebug>
      
      #include <stdio.h>
      #include <time.h>
      #include <locale.h>
      
      
      int main ()
      {
        time_t rawtime;
        struct tm * timeinfo;
        char buffer [80];
      
        struct lconv * lc;
      
        time ( &rawtime );
        timeinfo = localtime ( &rawtime );
      
        int twice=0;
      
        do {
      	printf("------\n");	
      
          printf ("C Locale is: %s\n", setlocale(LC_ALL,NULL) );
      
          strftime (buffer,80,"%c",timeinfo);
          printf ("Date is: %s\n",buffer);
      
          lc = localeconv ();
          printf ("Currency symbol is: %s\n-\n",lc->currency_symbol);
      
      	QLocale locale;
      	qDebug() << "QLocale name:" << locale.name();
      	qDebug() << "QLocale name(static):" << QLocale::system().name();
      
          setlocale (LC_ALL,"");
        } while (!twice++);
        
        return 0;
      }
      
      Unknown macro: {vl}

      [vl@qtbug]$ uname -a
      Linux vl 2.6.31-gentoo-r6 #3 SMP PREEMPT Fri Jan 1 22:13:49 MSK 2010 x86_64 Intel(R) Core(TM)2 Duo CPU E8500 @ 3.16GHz GenuineIntel GNU/Linux

      [vl@qtbug]$ echo $LANG
      ru_RU.UTF-8

      Unknown macro: {vl}

      [vl@qtbug]$ g++ -pipe -O2 -pipe -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/home/vl/opt/qtsdk-2010.02/qt/mkspecs/linux-g++ -I. -I/home/vl/opt/qtsdk-2010.02/qt/include/QtCore/ -I/home/vl/opt/qtsdk-2010.02/qt/include qt_app.cpp -L/home/vl/opt/qtsdk-2010.02/qt/lib -lQtCore -lgthread-2.0 -lrt -lglib-2.0 -lpthread -o qt_app

      [vl@qtbug]$ ldd ./qt_app
      linux-vdso.so.1 => (0x00007fff177c9000)
      libQtCore.so.4 => /home/vl/opt/qtsdk-2010.02/qt/lib/libQtCore.so.4 (0x00007fcb2f4bc000)
      libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007fcb2f2b7000)
      librt.so.1 => /lib/librt.so.1 (0x00007fcb2f0ae000)
      libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007fcb2edd3000)
      libpthread.so.0 => /lib/libpthread.so.0 (0x00007fcb2ebb7000)
      libstdc+.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.3.4/libstdc+.so.6 (0x00007fcb2e8ac000)
      libm.so.6 => /lib/libm.so.6 (0x00007fcb2e629000)
      libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fcb2e413000)
      libc.so.6 => /lib/libc.so.6 (0x00007fcb2e0ba000)
      libdl.so.2 => /lib/libdl.so.2 (0x00007fcb2deb6000)
      /lib64/ld-linux-x86-64.so.2 (0x00007fcb2f96d000)

      Unknown macro: {vl}

      [vl@qtbug]$ ./qt_app
      ------
      C Locale is: C
      Date is: Sun Mar 28 23:04:25 2010
      Currency symbol is:
      -
      QLocale name: "C"
      QLocale name(static): "C"
      ------
      C Locale is: LC_CTYPE=ru_RU.UTF-8;LC_NUMERIC=C;LC_TIME=ru_RU.UTF-8;LC_COLLATE=ru_RU.UTF-8;LC_MONETARY=ru_RU.UTF-8;LC_MESSAGES=ru_RU.UTF-8;LC_PAPER=ru_RU.UTF-8;LC_NAME=ru_RU.UTF-8;LC_ADDRESS=ru_RU.UTF-8;LC_TELEPHONE=ru_RU.UTF-8;LC_MEASUREMENT=ru_RU.UTF-8;LC_IDENTIFICATION=ru_RU.UTF-8
      Date is: Вск 28 Мар 2010 23:04:25
      Currency symbol is: руб
      -
      QLocale name: "C"
      QLocale name(static): "C"

      Attachments

        1. qt_app.cpp
          0.7 kB
        2. qt_app
          14 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dzyubenk Denis Dzyubenko (Inactive)
            vl409 VL
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes