Use boost locale together with Firebreath
Asked Answered
D

2

0

I create a chrome extension using Firebreath: http://slimtext.org And I meet a problem: the extension does not support Chinese characters very well on Windows. After a lot of research I found this: http://www.boost.org/doc/libs/1_50_0/libs/locale/doc/html/default_encoding_under_windows.html

I think the solution is to use boost/locale. But the https://github.com/firebreath/firebreath-boost project does not seem to contain boost/locale. The 1.50.0 branch contains newer boost than the master branch but neither of them contains boost/locale.

I tried to use external boost, or copy the locale code from external boost, but failed.(couldn't link to locale when doing make)

What's your suggestion? How can I Use boost locale together with Firebreath ?

Darrickdarrill answered 17/3, 2013 at 3:5 Comment(0)
D
0

I failed to compile my Firebreath project with external Boost on Windows. And after a lot of investigation, I start to doubt that boost/locale is the key to my original problem: Chinese characters encoding problem.

Finally I resolved it without boost/locale:

  1. use wstring instead of string whenever possible
  2. you might have to write code separately for windows and other operating systems, example:

#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

Darrickdarrill answered 18/3, 2013 at 1:58 Comment(1)
Note the firebreath functions FB::utf8_to_wstring and FB::wstring_to_utf8Wilscam
W
1

firebreath-boost is just a subset of the full boost. To use all of boost install boost manually and use system boost. see http://www.firebreath.org/display/documentation/Prep+Scripts

Wilscam answered 17/3, 2013 at 4:30 Comment(5)
Thank you for replying. I tried to compile and install the newest boost 1.53.0 and follow the instructions you post. Without any luck. Is firebreath compatible with boost 1.53.0 ?Darrickdarrill
You need to link boost systemWilscam
Do you have plans to add locale into firebreath-boost project? Then I can get the project running just as before. Now I have to do a lot of debugging and configuring. (I still cannot get it work on Windows). I think locale is very important for i18n. Otherwise firebreath cannot support languages other than othose ascii ones.Darrickdarrill
I have no such plans at present; I might look into it at some pointWilscam
It turns out the problem is very complex and I am not sure whether boost/locale is the key or not. Finally I resolved my original issue without it. See my answer.Darrickdarrill
D
0

I failed to compile my Firebreath project with external Boost on Windows. And after a lot of investigation, I start to doubt that boost/locale is the key to my original problem: Chinese characters encoding problem.

Finally I resolved it without boost/locale:

  1. use wstring instead of string whenever possible
  2. you might have to write code separately for windows and other operating systems, example:

#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

Darrickdarrill answered 18/3, 2013 at 1:58 Comment(1)
Note the firebreath functions FB::utf8_to_wstring and FB::wstring_to_utf8Wilscam

© 2022 - 2024 — McMap. All rights reserved.