std::locale系列--基本概念

起因

最近前百度同事咨询了一个问题

C++提供的正则库替换中文不成功

相应的基本代码逻辑大概是如下这样

std::string ori("中国。喜欢?开心。);
std::Regex reg("。?“);
std::string fmt("hello")
atuo str = std::regex_replace(ori,reg, fmt);

通过调研和测试,发现使用std::locale可以解决上述问题

在我调研中,我发现网上并没有关于std::locale的详细介绍,唯一找到帮助很大的资料如下Internationalization and Localization

中文资料基本没有什么系统的介绍,为此我决定将std::locale系统的整理出来,主要参考我上述的资料,如果你英语好,那么可以直接去阅读,如果想快速了解,那么也可以看我这一系列的介绍。

基本术语

Internationalization(国际化)

简单来说,就是设计的软件需要满足各个地域或者文化的需要。

学术一些的定义如下

Internationalization requires that developers consciously design and implement software for adaptation to various languages and cultural conventions, and avoid hard-coding elements that can be localized, like screen positions and file names. For example, developers should never embed in their code any messages, prompts, or other kind of displayed text, but rather store the messages externally, so they can be translated without requiring the program to be recompiled. A developer of internationalized software should never assume specific conventions for formatting numeric or monetary values, or for displaying date and time.

Localization(本地化)

本地化是实际使国际化软件适应特定地理或文化区域用户需求的过程。

学术一些的定义如下

Localization is the process of actually adapting internationalized software to the needs of users in a particular geographical or cultural area. It includes translation of messages by software translators. It requires the creation and availability of appropriate tables containing relevant local data for use in a given system. This typically is the function of system administrators and operating system vendors, who build facilities for these functions into the program execution environment. Users of internationalized software are involved in the process as well, when they select the local conventions they prefer from the set of conventions available in their environment.

Localizing Cultural Conventions

  • 语言

       英语:a-z

       中文:啊---

  •    数字

1,000,000.55

US

1.000.000,55

Germany

10,00,000.55

Nepal

  • 货币
  • 时间和日期
  • 排序
  • 字符编码

总结

本节主要简单的介绍一下本系列的背景以及相应的基本术语,下一节开始我们会详细讲解同std::locale相关的各个概念 原理及使用方式。

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qls315

感觉好可打赏几毛钱增强更新动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值