]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/regex/build/has_icu_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / regex / build / has_icu_test.cpp
CommitLineData
7c673cae
FG
1/*
2 *
3 * Copyright (c) 2010
4 * John Maddock
5 *
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 *
10 */
11
12#include <unicode/uversion.h>
13#include <unicode/utypes.h>
14#include <unicode/uchar.h>
15#include <unicode/coll.h>
16#include <boost/scoped_ptr.hpp>
17#include <iostream>
18#include <iomanip>
19
20#if defined(_MSC_VER) && !defined(_DLL)
21//#error "Mixing ICU with a static runtime doesn't work"
22#endif
23
24void print_error(UErrorCode err, const char* func)
25{
26 std::cerr << "Error from function " << func << " with error: " << ::u_errorName(err) << std::endl;
27}
28
29int main()
30{
1e59de90
TL
31#ifdef ICU_DATA_DIR
32 ::u_setDataDirectory(ICU_DATA_DIR);
33#endif
34
7c673cae
FG
35 // To detect possible binary mismatches between the installed ICU build, and whatever
36 // C++ std lib's we're using, we need to:
37 // * Make sure we call ICU C++ API's
38 // * Make sure we call std lib C++ API's as well (cout).
39 // * Be sure this program is run, not just built.
40 UErrorCode err = U_ZERO_ERROR;
41 UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, "GREEK SMALL LETTER ALPHA", &err);
42 std::cout << (int)c << std::endl;
43 if(err > 0)
44 {
45 print_error(err, "u_charFromName");
46 return err;
47 }
48 U_NAMESPACE_QUALIFIER Locale l;
49 boost::scoped_ptr<U_NAMESPACE_QUALIFIER Collator> p_col(U_NAMESPACE_QUALIFIER Collator::createInstance(l, err));
50 if(err > 0)
51 {
52 print_error(err, "Collator::createInstance");
53 return err;
54 }
55 return err > 0 ? err : 0;
56}