1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // REQUIRES: locale.en_US.UTF-8
11 // REQUIRES: locale.fr_CA.UTF-8
12
13 // <locale>
14
15 // template <class charT> class ctype_byname;
16
17 // char narrow(charT c, char dfault) const;
18
19 #include <locale>
20 #include <cassert>
21
22 #include "platform_support.h" // locale name macros
23
main()24 int main()
25 {
26 {
27 std::locale l(std::string(LOCALE_fr_CA_ISO8859_1));
28 {
29 typedef std::ctype<wchar_t> F;
30 const F& f = std::use_facet<F>(l);
31
32 assert(f.narrow(L' ', '*') == ' ');
33 assert(f.narrow(L'A', '*') == 'A');
34 assert(f.narrow(L'\x07', '*') == '\x07');
35 assert(f.narrow(L'.', '*') == '.');
36 assert(f.narrow(L'a', '*') == 'a');
37 assert(f.narrow(L'1', '*') == '1');
38 assert(f.narrow(L'\xDA', '*') == '\xDA');
39 }
40 }
41 {
42 std::locale l(LOCALE_en_US_UTF_8);
43 {
44 typedef std::ctype<wchar_t> F;
45 const F& f = std::use_facet<F>(l);
46
47 assert(f.narrow(L' ', '*') == ' ');
48 assert(f.narrow(L'A', '*') == 'A');
49 assert(f.narrow(L'\x07', '*') == '\x07');
50 assert(f.narrow(L'.', '*') == '.');
51 assert(f.narrow(L'a', '*') == 'a');
52 assert(f.narrow(L'1', '*') == '1');
53 assert(f.narrow(L'\xDA', '*') == '*');
54 }
55 }
56 }
57