]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/locale/examples/wconversions.cpp
2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
10 // ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
12 // BIG FAT WARNING FOR Microsoft Visual Studio Users
14 // YOU NEED TO CONVERT THIS SOURCE FILE ENCODING TO UTF-8 WITH BOM ENCODING.
16 // Unfortunately MSVC understands that the source code is encoded as
17 // UTF-8 only if you add useless BOM in the beginning.
19 // So, before you compile "wide" examples with MSVC, please convert them to text
20 // files with BOM. There are two very simple ways to do it:
22 // 1. Open file with Notepad and save it from there. It would convert
23 // it to file with BOM.
24 // 2. In Visual Studio go File->Advances Save Options... and select
25 // Unicode (UTF-8 with signature) Codepage 65001
27 // Note: once converted to UTF-8 with BOM, this source code would not
28 // compile with other compilers, because no-one uses BOM with UTF-8 today
29 // because it is absolutely meaningless in context of UTF-8.
31 // ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
33 #include <boost/locale.hpp>
34 #include <boost/algorithm/string/case_conv.hpp>
42 using namespace boost::locale
;
44 // Create system default locale
50 // This is needed to prevent C library to
51 // convert strings to narrow
52 // instead of C++ on some platforms
53 std::ios_base::sync_with_stdio(false);
56 wcout
<<L
"Correct case conversion can't be done by simple, character by character conversion"<<endl
;
57 wcout
<<L
"because case conversion is context sensitive and not 1-to-1 conversion"<<endl
;
58 wcout
<<L
"For example:"<<endl
;
59 wcout
<<L
" German grüßen correctly converted to "<<to_upper(L
"grüßen")<<L
", instead of incorrect "
60 <<boost::to_upper_copy(std::wstring(L
"grüßen"))<<endl
;
61 wcout
<<L
" where ß is replaced with SS"<<endl
;
62 wcout
<<L
" Greek ὈΔΥΣΣΕΎΣ is correctly converted to "<<to_lower(L
"ὈΔΥΣΣΕΎΣ")<<L
", instead of incorrect "
63 <<boost::to_lower_copy(std::wstring(L
"ὈΔΥΣΣΕΎΣ"))<<endl
;
64 wcout
<<L
" where Σ is converted to σ or to ς, according to position in the word"<<endl
;
65 wcout
<<L
"Such type of conversion just can't be done using std::toupper that work on character base, also std::toupper is "<<endl
;
66 wcout
<<L
"not fully applicable when working with variable character length like in UTF-8 or UTF-16 limiting the correct "<<endl
;
67 wcout
<<L
"behavoir to BMP or ASCII only"<<endl
;
71 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
73 // boostinspect:noascii