Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor refyl's Avatar
    Join Date
    Aug 2008
    Location
    Shenzheng
    Posts
    68
    编译时遇到下列错误:
    * RCOMP failed - deleting output files
    *** Unknown character '?' (value 0xffffffbb)
    *** Unknown character '?' (value 0xffffffbf)
    *** Unknown character '?' (value 0xffffffef)

    用二进制查看工具(如UE)打开资源文件(rls\RNN等) ,会发现文本前面多了三个乱码字符.删掉这三个字符就可以消除以上错误.

    我写了一段Python脚本,只要把脚本放在项目的根目录下,双击运行,就可以将项目中所有出错的文件修改过来.注意设置文件可写.

    Python源码如下(已测试过):

    Code:
    import struct,os;
    from os.path import join
    
    def main():
        for root,dirs,files in os.walk("./"):
            for name in files:
                clean(join(root,name));
    
    def clean(fileName):
        f=open(fileName,"rb");
        c=struct.unpack("3s", f.read(struct.calcsize("3s")));
        if c==('\xef\xbb\xbf',):
            f_temp=open(fileName+".temp","wb");
            while 1:
                line=f.readline();
                if line=="":
                    break;
                f_temp.writelines(line);
            f_temp.close();
            f.close();
            os.remove(fileName);
            os.rename(fileName+".temp", fileName);
        else:    
            f.close();
        
    if __name__=="__main__":
        main();
    Last edited by refyl; 2008-08-17 at 08:00.

  2. #2
    Regular Contributor refyl's Avatar
    Join Date
    Aug 2008
    Location
    Shenzheng
    Posts
    68
    增加将所有cpp文件由gb2312编码改为UTF8的功能(已测试).
    可以通过增删注释#的方法单独使用或全部使用

    Code:
    import struct,os;
    from os.path import join
    
    def main():
        for root,dirs,files in os.walk("./"):
            for name in files:
                #clean(join(root,name));
                if name.endswith('cpp'):
                    codeConvent(join(root,name),'gb2312','utf-8');
    
    def clean(fileName):
        f=open(fileName,"rb");
        c=struct.unpack("3s", f.read(struct.calcsize("3s")));
        if c==('\xef\xbb\xbf',):
            f_temp=open(fileName+".temp","wb");
            while 1:
                line=f.readline();
                if line=="":
                    break;
                f_temp.writelines(line);
            f_temp.close();
            f.close();
            os.remove(fileName);
            os.rename(fileName+".temp", fileName);
        else:    
            f.close();
    
    def codeConvent(fileName,oldCode,newCode):
        f=open(fileName,"r");
        f_temp=open(fileName+".temp","w");
        while 1:
            line=f.readline();
            if line=="":
                break;
            line=line.decode(oldCode,'ignore').encode(newCode);
            f_temp.writelines(line);
        f_temp.close();
        f.close();
        os.remove(fileName);
        os.rename(fileName+".temp", fileName);
      
        
    if __name__=="__main__":
        main();
    Good Good Study Day Day UP

  3. #3
    Nokia Developer Champion xhsoldier's Avatar
    Join Date
    May 2006
    Location
    Beijing,China
    Posts
    1,190
    我觉得你也可以直接使用hex editor直接就避免了你这个问题

  4. #4
    Regular Contributor refyl's Avatar
    Join Date
    Aug 2008
    Location
    Shenzheng
    Posts
    68
    当然可以,但是当此类项目文件多(100多个)的时候,自动化操作就很方便。
    Good Good Study Day Day UP

  5. #5
    Nokia Developer Champion xhsoldier's Avatar
    Join Date
    May 2006
    Location
    Beijing,China
    Posts
    1,190
    Quote Originally Posted by refyl View Post
    当然可以,但是当此类项目文件多(100多个)的时候,自动化操作就很方便。
    ”增加将所有cpp文件由gb2312编码改为UTF8的功能“
    有很多工具可以实现啊,甚至symbian也有这样的工具。

    anyway, it is good

    我只是有个建议,本地化编程的时候,首先要弄清楚IDE的编码环境,然后再确定目标的编码环境。

    例如carbide有可能是gd2312,但是symbian却又可能是UCS-2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved