summaryrefslogtreecommitdiff
path: root/boost/libs/regex/build/has_icu_test.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
committerChristoph Berg <myon@debian.org>2018-12-19 22:58:32 +0100
commite0737c56c1e384e05064a0c6e1ac46979371041b (patch)
treea0123d694a2d36c43dabdf0a3907392fce11d457 /boost/libs/regex/build/has_icu_test.cpp
parentb4aebf2d137b892f53503b13785ecae900062ff7 (diff)
New upstream version 2.0.0+repackupstream/2.0.0+repack
Diffstat (limited to 'boost/libs/regex/build/has_icu_test.cpp')
-rw-r--r--boost/libs/regex/build/has_icu_test.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/boost/libs/regex/build/has_icu_test.cpp b/boost/libs/regex/build/has_icu_test.cpp
new file mode 100644
index 00000000..31c964e7
--- /dev/null
+++ b/boost/libs/regex/build/has_icu_test.cpp
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright (c) 2010
+ * John Maddock
+ *
+ * Use, modification and distribution are subject to 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 <unicode/uversion.h>
+#include <unicode/utypes.h>
+#include <unicode/uchar.h>
+#include <unicode/coll.h>
+#include <boost/scoped_ptr.hpp>
+#include <iostream>
+#include <iomanip>
+
+#if defined(_MSC_VER) && !defined(_DLL)
+//#error "Mixing ICU with a static runtime doesn't work"
+#endif
+
+void print_error(UErrorCode err, const char* func)
+{
+ std::cerr << "Error from function " << func << " with error: " << ::u_errorName(err) << std::endl;
+}
+
+int main()
+{
+ // To detect possible binary mismatches between the installed ICU build, and whatever
+ // C++ std lib's we're using, we need to:
+ // * Make sure we call ICU C++ API's
+ // * Make sure we call std lib C++ API's as well (cout).
+ // * Be sure this program is run, not just built.
+ UErrorCode err = U_ZERO_ERROR;
+ UChar32 c = ::u_charFromName(U_UNICODE_CHAR_NAME, "GREEK SMALL LETTER ALPHA", &err);
+ std::cout << (int)c << std::endl;
+ if(err > 0)
+ {
+ print_error(err, "u_charFromName");
+ return err;
+ }
+ U_NAMESPACE_QUALIFIER Locale l;
+ boost::scoped_ptr<U_NAMESPACE_QUALIFIER Collator> p_col(U_NAMESPACE_QUALIFIER Collator::createInstance(l, err));
+ if(err > 0)
+ {
+ print_error(err, "Collator::createInstance");
+ return err;
+ }
+ return err > 0 ? err : 0;
+}