gpt4 book ai didi

c++ - 提升语言环境的特定于语言环境的 to_lower 问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:59:25 26 4
gpt4 key购买 nike

我正在根据 boost-locale 页面 http://www.boost.org/doc/libs/1_50_0/libs/locale/doc/html/conversions.html 尝试使用 boost::locale::to_upper 来执行特定于语言环境的大写字母

文本表明我应该能够在“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;
}

这是在 OSX (10.7.4) 上使用 Xcode (4.1)。我已经使用建议的选项 -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 - 我认为没有必要,因为我在构建中关闭了图标?

任何人都可以让我了解正在发生的事情/我做错了什么以及为什么我没有得到记录的预期行为 - 或者至少可以尝试一些事情吗?

干杯

克里斯

最佳答案

所以 XCODE 在我身上崩溃了(就像它经常发生的那样),一旦我重新启动它并重新构建项目,它就会请求 ICU 库并且不再需要 iconv 库 - 即如预期的那样。我想把那个归结为 XCODE 巫术。我将留下这个问题,因为它至少涵盖了如何在 OSX 上使用 ICU 构建增强语言环境。

关于c++ - 提升语言环境的特定于语言环境的 to_lower 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11562561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com