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 // <locale> 11 12 // template <class charT> class ctype_byname; 13 14 // char narrow(charT c, char dfault) const; 15 16 #include <locale> 17 #include <cassert> 18 19 #include "platform_support.h" // locale name macros 20 21 int main() 22 { 23 { 24 std::locale l(std::string(LOCALE_fr_CA_ISO8859_1)); 25 { 26 typedef std::ctype<wchar_t> F; 27 const F& f = std::use_facet<F>(l); 28 29 assert(f.narrow(L' ', '*') == ' '); 30 assert(f.narrow(L'A', '*') == 'A'); 31 assert(f.narrow(L'\x07', '*') == '\x07'); 32 assert(f.narrow(L'.', '*') == '.'); 33 assert(f.narrow(L'a', '*') == 'a'); 34 assert(f.narrow(L'1', '*') == '1'); 35 assert(f.narrow(L'\xDA', '*') == '\xDA'); 36 } 37 } 38 { 39 std::locale l(LOCALE_en_US_UTF_8); 40 { 41 typedef std::ctype<wchar_t> F; 42 const F& f = std::use_facet<F>(l); 43 44 assert(f.narrow(L' ', '*') == ' '); 45 assert(f.narrow(L'A', '*') == 'A'); 46 assert(f.narrow(L'\x07', '*') == '\x07'); 47 assert(f.narrow(L'.', '*') == '.'); 48 assert(f.narrow(L'a', '*') == 'a'); 49 assert(f.narrow(L'1', '*') == '1'); 50 assert(f.narrow(L'\xDA', '*') == '*'); 51 } 52 } 53 } 54