]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/locale/examples/wboundary.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>
40 using namespace boost::locale
;
43 // Create system default locale
49 // This is needed to prevent C library to
50 // convert strings to narrow
51 // instead of C++ on some platforms
52 std::ios_base::sync_with_stdio(false);
55 wstring text
=L
"Hello World! あにま! Linux2.6 and Windows7 is word and number. שָלוֹם עוֹלָם!";
59 boundary::wssegment_index
index(boundary::word
,text
.begin(),text
.end());
60 boundary::wssegment_index::iterator p
,e
;
62 for(p
=index
.begin(),e
=index
.end();p
!=e
;++p
) {
63 wcout
<<L
"Part ["<<*p
<<L
"] has ";
64 if(p
->rule() & boundary::word_number
)
66 if(p
->rule() & boundary::word_letter
)
68 if(p
->rule() & boundary::word_kana
)
69 wcout
<<L
"kana character(s) ";
70 if(p
->rule() & boundary::word_ideo
)
71 wcout
<<L
"ideographic character(s) ";
72 if(p
->rule() & boundary::word_none
)
73 wcout
<<L
"no word characters";
77 index
.map(boundary::character
,text
.begin(),text
.end());
79 for(p
=index
.begin(),e
=index
.end();p
!=e
;++p
) {
84 index
.map(boundary::line
,text
.begin(),text
.end());
86 for(p
=index
.begin(),e
=index
.end();p
!=e
;++p
) {
91 index
.map(boundary::sentence
,text
.begin(),text
.end());
93 for(p
=index
.begin(),e
=index
.end();p
!=e
;++p
) {
101 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
103 // boostinspect:noascii