Boost.Locale
boost::locale::util::locale_data Class Reference

Holder and parser for locale names/identifiers. More...

#include <boost/locale/util/locale_data.hpp>

Public Member Functions

 locale_data ()
 Default to C locale with US-ASCII encoding.
 
 locale_data (const std::string &locale_name)
 
const std::string & language () const
 Return language (usually 2 lowercase letters, i.e. ISO-639 or 'C')
 
const std::string & country () const
 Return country (usually 2 uppercase letters, i.e. ISO-3166)
 
const std::string & encoding () const
 Return encoding/codeset, e.g. ISO8859-1 or UTF-8.
 
locale_dataencoding (std::string new_encoding, bool uppercase=true)
 
const std::string & variant () const
 Return variant/modifier, e.g. euro or stroke.
 
bool is_utf8 () const
 Return iff the encoding is UTF-8.
 
bool parse (const std::string &locale_name)
 
std::string to_string () const
 

Detailed Description

Holder and parser for locale names/identifiers.

Constructor & Destructor Documentation

◆ locale_data()

boost::locale::util::locale_data::locale_data ( const std::string &  locale_name)
explicit

Construct from the parsed locale

See also
parse
Exceptions
std::invalid_argumentparsing failed

Member Function Documentation

◆ encoding()

locale_data & boost::locale::util::locale_data::encoding ( std::string  new_encoding,
bool  uppercase = true 
)

Set encoding, will be made uppercase by default as-if it was parsed Returns *this for chaining

◆ parse()

bool boost::locale::util::locale_data::parse ( const std::string &  locale_name)

Parse a locale identifier of the form [language[_territory][.codeset][@modifier]]

Allows a dash as the delimiter: [language-territory] Return true if the identifier is valid:

  • language is given and consists of ASCII letters
  • territory, if given, consists of ASCII letters
  • Any field started by a delimiter (_, -, ., @) is not empty Otherwise parsing is aborted. Valid values already parsed stay set, other are defaulted.

◆ to_string()

std::string boost::locale::util::locale_data::to_string ( ) const

Get a representation in the form [language[_territory][.codeset][@modifier]] codeset is omitted if it is US-ASCII


The documentation for this class was generated from the following file: