microsoft / microsoft/STL

<iostream>: unicode(0x2013) brings wcout to set badbit

Open
#869 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

when I want to print 0x2013 to wcout, wcout set badbit.

Command-line test case

C:\Temp>type repro.cpp
#include <iostream>
#include <io.h>
#include <fcntl.h>

int main() 
{
   wchar_t cc = 0x2013;
   //_setmode(_fileno(stdout),_O_U16TEXT); (1)
   std::wcout << cc << std::endl;
   std::wcout << L"wcout set badbit\n";
   return 0;
}

but when I uncomment line (1) it works.
is this deliberate behavior?

Visual Studio 2019 Version 16.5.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the repro.cpp command-line case and compare std::wcout behavior for wchar_t 0x2013 with and without _setmode(_fileno(stdout), _O_U16TEXT). Trace the relevant Windows console and stream-state handling, then establish whether the badbit result is intentional; done means a confirmed expected behavior or a focused regression test and fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.