zoukankan      html  css  js  c++  java
  • std::locale与boost::locale的学习

    1. 什么是facet, locale

    facet ['fæsɪt]的原意,是宝石切割出来的一个平面。

    locale[ləʊˈkæl],表示本地化,

    locale

    the container that holds all the required information about a specific culture, such as number formatting patterns, date and time formatting, currency, case conversion etc.

    而facet代表着locale中存放的某一种具体信息,比如字符转换、货币等等。

    可以通过use_facet得到某个locale中的一个facet

       1: std::ctype<char> const &ctype_facet = std::use_facet<std::ctype<char> >(some_locale);
       2: char upper_a = ctype_facet.toupper('a');

    也可以将某个locale浸透(imbue [ɪmˈbjuː])到某个stream中,使该stream按照该locale规定的本地化格式进行输出。

       1: cout.imbue(std::locale("en_US.UTF-8"));
       2: cout << 1345.45 << endl;
       3: cout.imbue(std::locale("ru_RU.UTF-8"));
       4: cout << 1345.45 << endl;

    你也可以创建自己的std::locale::facet的派生类,用来建立自定义的本地化规则,然后将其安装到某个locale对象中。

    boost::locale库就是通过这种方式扩展了std::locale库的内容。

  • 相关阅读:
    Linux文件系统介绍
    httpd 2.4连接php-fpm
    基于lnmp环境安装Discuz
    apache 与 php-fpm 几种处理方式
    Discuz!安装搭建
    Linux中实现文本过滤
    httpd-2.4安装配置
    firewall-cmd.man
    了解JSON
    JSTL和EL表达式
  • 原文地址:https://www.cnblogs.com/long123king/p/3520275.html
Copyright © 2011-2022 走看看