This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/16006] New: Conversions of numbers in fi_FI.UTF-8 produces incorrect UTF-8


It seems that Finnish numbers use a non-breaking space as the thousands
separator. This character (0xA0 I believe) is converted incorrectly to UTF-8
when using the UTF-8 locale and outputting numbers. This program demonstrates
the problem:

#include <iostream>

int main()
{
  std::cout.imbue(std::locale("fi_FI.UTF-8"));
  std::cout << 1224 << std::endl;
  
  setlocale(LC_ALL, "fi_FI.UTF-8");
  printf("%'d\n", 1224);
}

Compile it with "g++ tmp.cpp -o tmp -Wall". Then run "./tmp". It will output

ole:~/tmp$ ./tmp
1Â224
1Â 224

Note that libstdc++ converts the non-breaking space (you can see this character
by using .ISO-8859-1 instead of .UTF-8 in the program) into one character, which
is obviously not UTF-8, whereas libc converts the space into two.

I'm not from Finland myself, but a user of one of my programs had mysterious
crashes due to this problem - obviously they only occurs when the numbers become
greater than 1,000.

-- 
           Summary: Conversions of numbers in fi_FI.UTF-8 produces incorrect
                    UTF-8
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: olau at hardworking dot dk
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]