aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin-wide-mode.sh.cpp
blob: e13d79605f118e0ec382d19933d262f656e2ae4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// <iostream>

// wistream wcin;

// UNSUPPORTED: no-wide-characters
// REQUIRES: target={{.+}}-windows-{{.+}}

// FILE_DEPENDENCIES: test.dat
// RUN: %{build}
// RUN: cat test.dat | %{exec} %t.exe

// Check that wcin works, preserving the unicode characters, after switching
// stdin to wide mode.

#include <iostream>
#include <cassert>
#include <io.h>
#include <fcntl.h>

int main(int, char**) {
    _setmode(_fileno(stdin), _O_WTEXT);
    std::wstring str;
    std::wcin >> str;
    assert(str == L"1234\u20ac\u00e5\u00e4\u00f6");
    return 0;
}