小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Boost.Locale: Default Encoding under Microsoft Win...

 蘭亭文藝 2019-12-13

All modern operating systems use Unicode.

  • Unix operating system family use UTF-8 encoding by default.
  • Microsoft Windows had migrated to Wide/UTF-16 API. The narrow encodings had been deprecated and the native OS API became so called 'Wide API'

As a result of radically different approaches, it is very hard to write portable Unicode aware applications.

Boost Locale fully supports both narrow and wide API. The default character encoding is assumed to be UTF-8 on Windows.

So if the default operating system Locale is 'English_USA.1252' the default locale for Boost.Locale on Windows would be 'en_US.UTF-8'.

When the created locale object is installed globally then any libraries that use std::codecvt for conversion between narrow API and the native wide API would handle UTF-8 correctly.

A good example of such library is Boost.Filesystem v3.

For example

#include <boost/locale.hpp>#include <boost/filesystem/path.hpp>#include <boost/filesystem/fstream.hpp>int main(){ // Create and install global locale std::locale::global(boost::locale::generator().generate('')); // Make boost.filesystem use it boost::filesystem::path::imbue(std::locale()); // Now Works perfectly fine with UTF-8! boost::filesystem::ofstream hello('????.txt'); }

However such behavior may break existing software that assumes that the current encoding is single byte encodings like code page 1252.

boost::locale::generator class has a property use_ansi_encoding() that allows to change the behavior to legacy one and select an ANSI code page as default system encoding.

So, when the current locale is 'English_USA.1252' and the use_ansi_encoding is turned on then the default locale would be 'en_US.windows-1252'

Note:
winapi backend does not support ANSI encodings, thus UTF-8 encoding is always used for narrow characters.

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多