From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/locale/examples/boundary.cpp | 72 ++++++++++++++++ src/boost/libs/locale/examples/calendar.cpp | 71 ++++++++++++++++ src/boost/libs/locale/examples/collate.cpp | 40 +++++++++ src/boost/libs/locale/examples/conversions.cpp | 44 ++++++++++ src/boost/libs/locale/examples/hello.cpp | 41 ++++++++++ src/boost/libs/locale/examples/wboundary.cpp | 104 ++++++++++++++++++++++++ src/boost/libs/locale/examples/wconversions.cpp | 73 +++++++++++++++++ src/boost/libs/locale/examples/whello.cpp | 45 ++++++++++ 8 files changed, 490 insertions(+) create mode 100644 src/boost/libs/locale/examples/boundary.cpp create mode 100644 src/boost/libs/locale/examples/calendar.cpp create mode 100644 src/boost/libs/locale/examples/collate.cpp create mode 100644 src/boost/libs/locale/examples/conversions.cpp create mode 100644 src/boost/libs/locale/examples/hello.cpp create mode 100644 src/boost/libs/locale/examples/wboundary.cpp create mode 100644 src/boost/libs/locale/examples/wconversions.cpp create mode 100644 src/boost/libs/locale/examples/whello.cpp (limited to 'src/boost/libs/locale/examples') diff --git a/src/boost/libs/locale/examples/boundary.cpp b/src/boost/libs/locale/examples/boundary.cpp new file mode 100644 index 00000000..7c643f93 --- /dev/null +++ b/src/boost/libs/locale/examples/boundary.cpp @@ -0,0 +1,72 @@ +// +// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +#include +#include +#include +#include + +int main() +{ + using namespace boost::locale; + using namespace std; + + generator gen; + // Make system default locale global + std::locale loc = gen(""); + locale::global(loc); + cout.imbue(loc); + + + string text="Hello World! あにま! Linux2.6 and Windows7 is word and number. שָלוֹם עוֹלָם!"; + + cout<rule() & boundary::word_number) + cout<<"number(s) "; + if(p->rule() & boundary::word_letter) + cout<<"letter(s) "; + if(p->rule() & boundary::word_kana) + cout<<"kana character(s) "; + if(p->rule() & boundary::word_ideo) + cout<<"ideographic character(s) "; + if(p->rule() & boundary::word_none) + cout<<"no word characters"; + cout< +#include +#include +#include + +int main() +{ + using namespace boost::locale; + + generator gen; + std::locale::global(gen("")); + std::cout.imbue(std::locale()); + // Setup environment + + boost::locale::date_time now; + + date_time start=now; + + // Set the first day of the first month of this year + start.set(period::month(),now.minimum(period::month())); + start.set(period::day(),start.minimum(period::day())); + + int current_year = period::year(now); + + + // Display current year + std::cout << format("{1,ftime='%Y'}") % now << std::endl; + + // + // Run forward untill current year is the date + // + for(now=start; period::year(now) == current_year;) { + + // Print heading of month + if(calendar().is_gregorian()) + std::cout << format("{1,ftime='%B'}") % now < +#include +#include + +#include + +using namespace std; +using namespace boost::locale; + +int main() +{ + generator gen; + std::locale::global(gen("")); + /// Set global locale to requested + + /// Create a set that includes all strings sorted according to ABC order + /// std::locale can be used as object for comparison + typedef std::set set_type; + set_type all_strings; + + /// Read all strings into the set + while(!cin.eof()) { + std::string tmp; + getline(cin,tmp); + all_strings.insert(tmp); + } + /// Print them out + for(set_type::iterator p=all_strings.begin();p!=all_strings.end();++p) { + cout<<*p< +#include +#include + +#include + + + +int main() +{ + using namespace boost::locale; + using namespace std; + // Create system default locale + generator gen; + locale loc=gen(""); + locale::global(loc); + cout.imbue(loc); + + + cout<<"Correct case conversion can't be done by simple, character by character conversion"< +#include + +#include + +int main() +{ + using namespace boost::locale; + using namespace std; + generator gen; + locale loc=gen(""); + // Create system default locale + + locale::global(loc); + // Make it system global + + cout.imbue(loc); + // Set as default locale for output + + cout <Advances Save Options... and select +// Unicode (UTF-8 with signature) Codepage 65001 +// +// Note: once converted to UTF-8 with BOM, this source code would not +// compile with other compilers, because no-one uses BOM with UTF-8 today +// because it is absolutely meaningless in context of UTF-8. +// +// ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! +// +#include +#include +#include +#include + +int main() +{ + using namespace boost::locale; + using namespace std; + + // Create system default locale + generator gen; + locale loc=gen(""); + locale::global(loc); + wcout.imbue(loc); + + // This is needed to prevent C library to + // convert strings to narrow + // instead of C++ on some platforms + std::ios_base::sync_with_stdio(false); + + + wstring text=L"Hello World! あにま! Linux2.6 and Windows7 is word and number. שָלוֹם עוֹלָם!"; + + wcout<rule() & boundary::word_number) + wcout<rule() & boundary::word_letter) + wcout<rule() & boundary::word_kana) + wcout<rule() & boundary::word_ideo) + wcout<rule() & boundary::word_none) + wcout<Advances Save Options... and select +// Unicode (UTF-8 with signature) Codepage 65001 +// +// Note: once converted to UTF-8 with BOM, this source code would not +// compile with other compilers, because no-one uses BOM with UTF-8 today +// because it is absolutely meaningless in context of UTF-8. +// +// ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! +// +#include +#include +#include + +#include + + +int main() +{ + using namespace boost::locale; + using namespace std; + // Create system default locale + generator gen; + locale loc=gen(""); + locale::global(loc); + wcout.imbue(loc); + + // This is needed to prevent C library to + // convert strings to narrow + // instead of C++ on some platforms + std::ios_base::sync_with_stdio(false); + + + wcout< +#include + +#include + +int main() +{ + using namespace boost::locale; + using namespace std; + + // Create system default locale + generator gen; + locale loc=gen(""); + locale::global(loc); + wcout.imbue(loc); + + // This is needed to prevent C library to + // convert strings to narrow + // instead of C++ on some platforms + std::ios_base::sync_with_stdio(false); + + + wcout <