项目中的一个文件原来不知道是什么编码写的。。 用记事本打开时正常的。
比如下面的
<Attachments>
<Attachment RelPath="C:\Documents and Settings\Administrator\桌面\素材\0913R1.files\images\0913R1_c_1.jpg"/>
<Attachment RelPath="C:\Documents and Settings\Administrator\桌面\素材\0913R1.files\images\0913R1_c_2.jpg"/>
<Attachment RelPath="C:\Documents and Settings\Administrator\桌面\素材\0913R1.files\images\0913R1_c_3.jpg"/>
<Attachment RelPath="images\thumb_01.jpg"/>
</Attachments>
我在程序中用open函数在_O_READ 模式下打开,结果但不调试的时候显示
:\Documents and Settings\Administrator\妗岄潰\绱犳潗\0913R1.files\images\0913R1_c_1.jpg
中文就是乱码了。 然后我复制上面的内容新建一个记事本保存后,有同样的方式打开就是正确的,不出现乱码,这个是为什么,我怎么才能直接获得正确 RelPath而非乱码,卡在这里两天了,各位帮忙。。
比如下面的
<Attachments>
<Attachment RelPath="C:\Documents and Settings\Administrator\桌面\素材\0913R1.files\images\0913R1_c_1.jpg"/>
<Attachment RelPath="C:\Documents and Settings\Administrator\桌面\素材\0913R1.files\images\0913R1_c_2.jpg"/>
<Attachment RelPath="C:\Documents and Settings\Administrator\桌面\素材\0913R1.files\images\0913R1_c_3.jpg"/>
<Attachment RelPath="images\thumb_01.jpg"/>
</Attachments>
我在程序中用open函数在_O_READ 模式下打开,结果但不调试的时候显示
:\Documents and Settings\Administrator\妗岄潰\绱犳潗\0913R1.files\images\0913R1_c_1.jpg
中文就是乱码了。 然后我复制上面的内容新建一个记事本保存后,有同样的方式打开就是正确的,不出现乱码,这个是为什么,我怎么才能直接获得正确 RelPath而非乱码,卡在这里两天了,各位帮忙。。
return -1;
char szBuffer[10*1024]={0};
int nReadBytes=0;
if( ( nReadBytes = read( fd, szBuffer, sizeof(szBuffer) ) )<= 0 ) //数据全部在szBuffer中
这样子行不行?
如果是:你必须用binary模式打开,读进来一行用W2A转换