专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Brew

写文件乱码有关问题!模拟器没有有关问题,真机乱码!

发布时间:2010-05-30 20:18:11 文章来源:www.iduyao.cn 采编人员:星星草
写文件乱码问题!!模拟器没有问题,真机乱码!!!!
C/C++ code

static int Write(ILog* a_pMe,const char* pFormat,...)
{
#ifdef _DEBUG_
    Loger*                      pMe=(Loger*)a_pMe;
    IFile *                      pFile=pMe->m_pFile; 

    // declare time 
    JulianType                   pDate;
    char*                         pTime;

    // declare log content.
    char*                      pLogContent;
    char                      nn[1024];
    va_list                      cArguments;

    if (pFormat==NULL)
        return EFAILED;    

    MEMSET(nn,0,1024);
    //malloc of pointer.
    pTime=(char*)MALLOC(sizeof(char)*SIZE);
    pLogContent = (char*)MALLOC(sizeof(char)*SIZE);

    // get current time and write into file.
    GETJULIANDATE(0,&pDate);
    SPRINTF(pTime,"[%4d-%02d-%02d %02d:%02d:%02d]:",pDate.wYear,pDate.wMonth,\
        pDate.wDay,pDate.wHour,pDate.wMinute,pDate.wSecond);
    IFILE_Write(pFile, pTime, STRLEN(pTime));

//   定位是这个地方出了问题!!但是不知道怎么解决
    va_start(cArguments, pFormat);
    VSPRINTF(pLogContent,pFormat,cArguments);
    SPRINTF(nn,"%s",pLogContent);
    IFILE_Write(pFile, pLogContent, STRLEN(pLogContent));    
    va_end(cArguments);

    //free the pointer 
    FREEIF(pTime)
    FREEIF(pLogContent);

    //cut line.
    IFILE_Write(pFile, "\r\n----------------\r\n", STRLEN("\r\n----------------\r\n"));
    return SUCCESS;
#endif
}



这段代码 当调用Write(“logloglog”);时时没有问题的,真机 模拟器也不会出现问题
当时当我 Write(“%s”,“this is a test”);就真机上就出现乱码了!!模拟器是正常的!!!


sdk 3.1.5 
vs 2005


各位请指教


------解决方案--------------------
是不是文件中保存UNIcode编码数据啊,所以你看到的是乱码,用Utraedit看看,每个字节是什么东西
------解决方案--------------------
和文件的编码有关系吧
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: