【问题标题】:Use boost locale together with Firebreath将 boost locale 与 Firebreath 一起使用
【发布时间】:2013-03-17 03:05:29
【问题描述】:

我使用 Firebreath 创建了一个 chrome 扩展:http://slimtext.org 我遇到了一个问题:该扩展在 Windows 上不能很好地支持中文字符。经过大量研究,我发现:http://www.boost.org/doc/libs/1_50_0/libs/locale/doc/html/default_encoding_under_windows.html

我认为解决方案是使用 boost/locale。但是https://github.com/firebreath/firebreath-boost 项目似乎不包含 boost/locale。 1.50.0 分支包含比 master 分支更新的 boost,但它们都不包含 boost/locale。

我尝试使用外部 boost,或者从外部 boost 复制语言环境代码,但失败了。(在 make 时无法链接到语言环境)

你有什么建议?如何将 boost 语言环境与 Firebreath 一起使用?

【问题讨论】:

    标签: firebreath boost-locale


    【解决方案1】:

    firebreath-boost 只是完整提升的一个子集。要使用所有 boost 手动安装 boost 并使用系统 boost。见http://www.firebreath.org/display/documentation/Prep+Scripts

    【讨论】:

    • 感谢您的回复。我尝试编译和安装最新的 boost 1.53.0 并按照您发布的说明进行操作。没有任何运气。 firebreath 与 boost 1.53.0 兼容吗?
    • 你需要链接升压系统
    • 您有计划将语言环境添加到 firebreath-boost 项目中吗?然后我可以让项目像以前一样运行。现在我必须做很多调试和配置。 (我仍然无法让它在 Windows 上运行)。我认为语言环境对 i18n 非常重要。否则,firebreath 无法支持除 ascii 以外的其他语言。
    • 我目前没有这样的计划;我可能会在某个时候调查一下
    • 事实证明问题非常复杂,我不确定 boost/locale 是否是关键。最后我解决了没有它的原始问题。看我的回答。
    【解决方案2】:

    我未能在 Windows 上使用外部 Boost 编译我的 Firebreath 项目。而且经过大量调查,我开始怀疑 boost/locale 是我原来问题的关键:汉字编码问题。

    最后我在没有 boost/locale 的情况下解决了它:

    1. 尽可能使用 wstring 代替字符串
    2. 您可能需要为 Windows 和其他操作系统分别编写代码,例如:

    #ifdef _WIN32

        file.open(path.c_str()); //path is std::wstring
    

    #else

        fs::path the_path(path);            
        file.open(the_path.generic_string().c_str());
    

    #endif

    【讨论】:

    • 注意firebreath函数FB::utf8_to_wstring和FB::wstring_to_utf8
    猜你喜欢
    • 2016-04-17
    • 2017-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    • 2011-02-19
    • 2011-12-10
    相关资源
    最近更新 更多