宽字符支持(linux,MinGW,Qt)
1。要使用宽字符支持,使用w开头的一系列东西,如wstring,wofstream等。在使用wstring的时候,常量字符串前面要加上L,这样才能转换成wchar_t型的
else if(fileName.substr(fileName.rfind(L"."))==L".prj")
2。一个文件流(无论是ofstream还是wofstream),只支持const char*作为文件名,对于宽字符的wstring的文件名,该做一些处理。
DTchar mbsFileName[512];
DTint mbsSize=std::wcstombs(mbsFileName,m_dumpFileName.c_str(),m_dumpFileName.size()*sizeof(wchar_t));
mbsFileName[mbsSize]=0;
m_pDumpStream=new std::fstream(mbsFileName,std::ios::out|std::ios::binary);
上面的代码要注意的是,wcstombs转换后的char序列并没有0字符串结尾符,所以拿出去直接当字符串使用会出错。
或者“You can use wcstombs() to narrow the filename or if you're feeling adventurous, the narrow() member function of the ctype facet of a std::locale.”
见http://www.gamedev.net/community/forums/topic.asp?topic_id=358254&whichpage=1?
3。MinGW不支持wchar_t,好像是因为linux下的wchar_t是4字节的,而windows下vc运行时的wchar_t是2字节的。
见Qt中qstring.cpp中的一段doxygen注释
#ifndef QT_NO_STL
/*! fn QString QString::fromStdWString(const std::wstring &str)
Returns a copy of a str. a str is assumed to be encoded in
utf16 if the size of wchar_t is 2 bytes (e.g. on windows) and ucs4
if the size of wchar_t is 4 bytes (most Unix systems).
This constructor is only available if Qt is configured with STL
compabitility enabled.
sa fromUtf16(), fromLatin1(), fromLocal8Bit(), fromUtf8()
*/
见MinGW的官方声明:http://www.mingw.org/MinGWiki/index.php/wide%20characters
其中还有2个连接。
另外:一个hp的家伙hack的方法:
http://lists.zerezo.com/mingw-users/msg00753.html
很复杂,我又不懂,唉。。。。绝望。
在linux下的支持宽字符的,没法在windows下移植了。。。。。。。。。。
4.MinGW下的Qt是支持宽字符的,我还测试了一下,如果文件路径中含有“桌面”二字,我的非宽字符支持的程序会r
相关文档:
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include<linux/config.h>
#include<linux/module.h>
#include<linux/version.h>
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/errno.h>
#include<linux/sche ......
-------------------------------------------------------------------------------------------------------
//By:yuyongbao
//QQ:673360056
Linux下用Busy Box制作Ramdisk全过程
1 建立根文件系统结构
#mkdir rootfs
#cd rootfs
#mkdir bin dev etc lib proc sbin tmp usr var
#chmod 1777 tmp
#mk ......
·find path -option [ -print ] [ -exec -ok command ] {} \;
#-print 将查找到的文件输出到标准输出
#-exec command {} \; -----将查到的文件执行command操作,{} 和 \;之间有空格
#-ok 和-exec相同,只不过在操作前要询 ......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
Linux
世界很精彩,令人眼花缭乱。近期以来,各种轻型
Linux
版本不断登台亮相,知名的
Puppy
(小狗之名)便是一例。何故?
......