我正在尝试使用 boost::locale::to_upper 根据 boost-locale 页面http://www.boost.org/doc/libs/1_50_0/libs/locale/doc/html进行特定于区域设置的大写/conversions.html
文本表明我应该能够在 'grüßEN' 上使用 boost::locale::to_upper 并得到结果 'GRÜSSEN' - 这是正确的特定于语言环境的大写版本(所以我相信)。
在我的测试版本中,我得到的是“GRÜßEN”而不是“GRÜSSEN”。
我的测试代码看起来像这样(我使用 utf8cpp 来检查我的字符串实际上是 utf8):
boost::locale::generator gen;
std::locale loc= gen("de_DE.UTF-8");
std::locale::global(loc);
cout.imbue(loc);
string s = "grüßEN";
if (utf8::is_valid(s.begin(), s.end())){
std::cout << s << " U= "<< boost::locale::to_upper(s) << std::endl;
}
这是在使用 Xcode (4.1) 的 OSX (10.7.4) 上。我已经使用 -DU_USING_ICU_NAMESPACE=0 -DU_CHARSET_IS_UTF8=1 的建议选项安装了 ICU (49_1_2)。ICU 位于 /usr/local/include/unicode 中,库位于 /usr/local/lib/libicu*.*
我从 1_48 套件中构建了 boost::locale,如下所示:
./bjam boost.locale.iconv=off -sICU_PATH=/usr/local --with-locale stage
并在构建时报告:
Performing configuration checks
- icu : yes
Component configuration:
- chrono : not building
- date_time : not building
- exception : not building
- filesystem : not building
- graph : not building
- graph_parallel : not building
- iostreams : not building
- locale : building
- math : not building
- mpi : not building
- program_options : not building
- python : not building
- random : not building
- regex : not building
- serialization : not building
- signals : not building
- system : not building
- test : not building
- thread : not building
- timer : not building
- wave : not building
...patience...
...patience...
...found 1850 targets...
...updating 25 targets...
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv- off/threading-multi/encoding/codepage.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/boundary.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/codecvt.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/collator.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/conversion.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/date_time.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/formatter.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/icu_backend.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/numeric.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/icu/time_zone.o
darwin.link.dll bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/threading-multi/libboost_locale.dylib
common.copy stage/lib/libboost_locale.dylib
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv- off/link-static/threading-multi/encoding/codepage.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/boundary.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/codecvt.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/collator.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/conversion.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/date_time.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/formatter.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/icu_backend.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/numeric.o
darwin.compile.c++ bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/time_zone.o
darwin.archive bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/libboost_locale.a
/usr/bin/libtool: warning same member name (codecvt.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link- static/threading-multi/std/codecvt.o and: bin.v2/libs/locale/build/darwin- 4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/posix/codecvt.o (due to use of basename, truncation, blank padding or duplicate input files)
/usr/bin/libtool: warning same member name (codecvt.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/posix/codecvt.o and: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/codecvt.o (due to use of basename, truncation, blank padding or duplicate input files)
/usr/bin/libtool: warning same member name (collate.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/std/collate.o and: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/posix/collate.o (due to use of basename, truncation, blank padding or duplicate input files)
/usr/bin/libtool: warning same member name (converter.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/std/converter.o and: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/posix/converter.o (due to use of basename, truncation, blank padding or duplicate input files)
/usr/bin/libtool: warning same member name (date_time.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/date_time.o and: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/shared/date_time.o (due to use of basename, truncation, blank padding or duplicate input files)
/usr/bin/libtool: warning same member name (numeric.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/icu/numeric.o and: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/posix/numeric.o (due to use of basename, truncation, blank padding or duplicate input files)
/usr/bin/libtool: warning same member name (numeric.o) in output file used for input files: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/posix/numeric.o and: bin.v2/libs/locale/build/darwin-4.2.1/release/boost.locale.iconv-off/link-static/threading-multi/std/numeric.o (due to use of basename, truncation, blank padding or duplicate input files)
common.copy stage/lib/libboost_locale.a
...updated 25 targets...
根据https://svn.boost.org/trac/boost/ticket/6424,可以忽略警告(或者有人知道吗?)我将构建的库从 stage/libs 复制到 /usr/local/libs。
据我所知,它是针对 ICU 正确构建的。我的测试代码确实需要我链接到 libiconv - 我会认为这不是必需的,因为我在构建中关闭了图标?
谁能让我深入了解正在发生的事情/我做错了什么以及为什么我没有得到记录的预期行为 - 或者至少有一些事情可以尝试?
干杯
克里斯