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)
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>
20 #if defined(_MSC_VER) && !defined(_DLL)
21 //#error "Mixing ICU with a static runtime doesn't work"
24 void print_error(UErrorCode err
, const char* func
)
26 std::cerr
<< "Error from function " << func
<< " with error: " << ::u_errorName(err
) << std::endl
;
31 // To detect possible binary mismatches between the installed ICU build, and whatever
32 // C++ std lib's we're using, we need to:
33 // * Make sure we call ICU C++ API's
34 // * Make sure we call std lib C++ API's as well (cout).
35 // * Be sure this program is run, not just built.
36 UErrorCode err
= U_ZERO_ERROR
;
37 UChar32 c
= ::u_charFromName(U_UNICODE_CHAR_NAME
, "GREEK SMALL LETTER ALPHA", &err
);
38 std::cout
<< (int)c
<< std::endl
;
41 print_error(err
, "u_charFromName");
44 U_NAMESPACE_QUALIFIER Locale l
;
45 boost::scoped_ptr
<U_NAMESPACE_QUALIFIER Collator
> p_col(U_NAMESPACE_QUALIFIER
Collator::createInstance(l
, err
));
48 print_error(err
, "Collator::createInstance");
51 return err
> 0 ? err
: 0;