ansi、unico、utf8

来源:互联网 发布:mac预览怎么编辑pdf 编辑:程序博客网 时间:2024/06/09 22:40

几种编码的区别

ASCII码–>ansi–>gb2312
Unicode—>utf8\utf16(UTF-8是Unicode的实现方式之一)
http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html

UTF-8(无BOM)和UTF-8这两个有什么区别呢?BOM是什么呀?

BOM: Byte Order Mark
UTF-8 BOM又叫UTF-8 签名,其实UTF-8 的BOM对UFT-8没有作用,是为了支持UTF-16,UTF-32才加上的
BOM,BOM签名的意思就是告诉编辑器当前文件采用何种编码,方便编辑器识别,但是BOM虽然在编辑器中不显示,但是会产生输出,就像多了一个空行。
一般我用UTF-8无BOM格式

//string与wstring转换 http://blog.csdn.net/mao_mao37/article/details/51122512BOOL StringToWString(const std::string &str,std::wstring &wstr) {         int nLen = (int)str.length();         wstr.resize(nLen,L' ');     int nResult = MultiByteToWideChar(CP_ACP,0,(LPCSTR)str.c_str(),nLen,(LPWSTR)wstr.c_str(),nLen);     if (nResult == 0)     {         return FALSE;     }     return TRUE; } //wstring高字节不为0,返回FALSE BOOL WStringToString(const std::wstring &wstr,std::string &str) {         int nLen = (int)wstr.length();         str.resize(nLen,' ');     int nResult = WideCharToMultiByte(CP_ACP,0,(LPCWSTR)wstr.c_str(),nLen,(LPSTR)str.c_str(),nLen,NULL,NULL);     if (nResult == 0)     {         return FALSE;     }     return TRUE; }
原创粉丝点击