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

| Boost.Locale

Public Member Functions | List of all members
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 & | script () const
| Return the ISO-15924 abbreviation script code if present.
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_data & | encoding (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_argument | parsing 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[_script][_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
- `script` is only considered if it consists of exactly 4 ASCII letters
- `territory`, if given, consists of ASCII letters (usually ISO-3166)
- 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:

- boost/locale/util/locale_data.hpp

- © Copyright 2009-2012 Artyom Beilis, Distributed under the Boost Software License, Version 1.0.