incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-208) codecvt_byname("utf-8@UCS") conversion error
Date Wed, 28 Jun 2006 17:37:30 GMT
codecvt_byname("utf-8@UCS") conversion error
--------------------------------------------

         Key: STDCXX-208
         URL: http://issues.apache.org/jira/browse/STDCXX-208
     Project: C++ Standard Library
        Type: Bug

  Components: 22. Localization  
    Versions: 4.1.2, 4.1.3    
 Environment: all
    Reporter: Martin Sebor


Moved from Rogue Wave bug tracking database:

****Created By: sebor @ Oct 12, 2004 06:45:35 PM****
The program below produces 'conversion error' on stderr when run like so:

$ echo "abcd" | ./t utf-8@UCS utf-8@UCS
conversion error

The expected output is 'abcd'

#include <iostream>
#include <locale>

int main (int argc, char *argv [])
{
    typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> wcodecvt;

    const char* const from_name = argc > 1 ? argv [1] : "";
    const char* const to_name   = argc > 2 ? argv [2] : "";

    const wcodecvt from_cvt (from_name, 1);
    const wcodecvt to_cvt (to_name, 1);

    const std::locale from (std::wcin.getloc (), &from_cvt);
    const std::locale to (std::wcin.getloc (), &to_cvt);

    std::wcin.imbue (from);
    std::wcout.imbue (to);

    std::wcout << std::wcin.rdbuf ();

    if (std::wcout.rdstate ())
        std::cerr << "conversion error\n";

    std::wcout << std::flush;
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message