[llvm-bugs] [Bug 24929] New: std::wcin cannot read a multibyte character sequence

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 24 11:25:45 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24929

            Bug ID: 24929
           Summary: std::wcin cannot read a multibyte character sequence
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kariya_mitsuru at hotmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

Please see the sample code below.

========================= sample code =========================
#include <iostream>
#include <locale>

int main()
{
    std::wcin.imbue(std::locale("en_US.UTF-8"));
    wchar_t c;
    if (std::wcin >> c) {
        std::cout << std::hex << static_cast<int>(c) << '\n';
    } else {
        std::cout << "error!\n";
    }
}
========================= sample code =========================
=================== standard input (utf-8) ===================
ü(u umlaut)
=================== standard input (utf-8) ===================
========================= output =========================
error!
========================= output =========================
cf. http://melpon.org/wandbox/permlink/1gZAq81rbJMvGm0p


I think that the character "ü"(u umlaut) is a valid character on
the locale en_US.UTF-8, so an output should be

======================= desired output =======================
fc
======================= desired output =======================

Note that wifstream can read a multibyte sequence correctly.
cf. http://melpon.org/wandbox/permlink/9reHs5foneZCi2RF

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150924/8e6b28a7/attachment.html>


More information about the llvm-bugs mailing list