Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8778843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:37:43+00:00 2026-06-13T19:37:43+00:00

I try to understand how to use boost::locale to compare strings ignoring case and

  • 0

I try to understand how to use boost::locale to compare strings ignoring case and variants. I directly tried a code from Boost documentation :

http://www.boost.org/doc/libs/1_51_0/libs/locale/doc/html/collation.html

boost::locale::generator gen;
std::locale vLocale = gen("");


std::wstring a=L"Façade", b=L"facade";

// Following will throw bad_cast
bool eq = std::use_facet<boost::locale::collator<wchar_t>>(vLocale).compare(
    boost::locale::collator_base::secondary,
    a,
    b
) == 0;

if(eq) std::cout << "OK" << std::endl;

This code will throw a std::bad_cast exception when running.
I tried a lot of parameters in the constructor of boost::locale::generator. Does anyone know about the problem I encounter ?

I am using C++11 with g++4.6 and Boost 1.51.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:37:44+00:00Added an answer on June 13, 2026 at 7:37 pm

    It seems you are using an incorrect locale object. First, you should use global locale and then (if you want to use std::cout) imbue the locale to the stream. Something like this:

    boost::locale::generator gen;
    std::locale loc = gen("");
    std::locale::global(loc);
    

    But, in your example, if you are not using std::cout, just set global locale so you have the required facets ready.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to understand the ICommand from wpf. In my Event class I implement
I try to understand this example from jquery api in this snippet var tags
I'm new to win32 API programming and I try to understand source code of
I try to compare Mnesia with more traditional databases. As I understand it tables
I want to try to understand the use of these constructs because I don't.
Please tell me how to use try/catch properly with boost::exception. This is one of
I have tried everything to try understand what the if part of this statement
I try to understand what is really happening when you want to make use
I try to understand how use ksoap on Android. I have executed this ksoap
I try to understand the regex in python. How can i split the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.