Project1

标题: 模拟print函数出现了乱码 [打印本页]

作者: 奶油Da蛋糕    时间: 2009-10-31 07:38
标题: 模拟print函数出现了乱码
本帖最后由 奶油Da蛋糕 于 2009-10-31 09:28 编辑
  1. def print(text)
  2. a = File.open("Game.ini")
  3.   b = a.readlines
  4.   a.close
  5.   for i in 0..b.size
  6.     a = b[i]
  7.     if a.include?("Title")  
  8.       tit = a.split(/=/)[1]
  9.       break      
  10.       end
  11.     end
  12. Win32API.new('user32','MessageBox',%w{L P P L},'I').call(0,text,tit,0)
  13. end
复制代码
  1. print "研究API是一件很复杂的事情!"
复制代码
---------------------------
API研究专用工程

---------------------------
鐮旂┒API鏄竴浠跺緢澶嶆潅鐨勪簨鎯咃紒
---------------------------
确定   
---------------------------

请问出现乱码的原因大概是什么?
作者: 倭卜僾伱    时间: 2009-10-31 07:42
http://211.91.172.65/mu/magicwin13f.rar

把上面这个下载下来

把乱码翻译一下即可
作者: 奶油Da蛋糕    时间: 2009-10-31 08:28
http://211.91.172.65/mu/magicwin13f.rar

把上面这个下载下来

把乱码翻译一下即可
倭卜僾伱 发表于 2009-10-31 07:42


晕...乱码的原因出在我使用API的时候可能用了错误的值吧,难道别人想玩我的游戏还得去下个软件翻译乱码?
作者: 上帝的眼睛    时间: 2009-10-31 09:12
本帖最后由 上帝的眼睛 于 2009-10-31 09:18 编辑

感觉应该是编码错误
http://rpg.blue/viewthread.php?tid=135516&highlight=%2BNOSCBY
注意看4楼紫苏的回复
作者: 奶油Da蛋糕    时间: 2009-10-31 09:27
  1. def print(text)
  2. a = File.open("Game.ini")
  3.   b = a.readlines
  4.   a.close
  5.   for i in 0..b.size
  6.     a = b[i]
  7.     if a.include?("Title")  
  8.       tit = a.split(/=/)[1]
  9.       break      
  10.       end
  11.     end
  12. # API掕媊
  13.    m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  14.    w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')

  15. # UTF-8 -> Unicode
  16.    len = m2w.call(65001, 0, text, -1, nil, 0);
  17.    buf = "\0" * (len*2)
  18.    m2w.call(65001, 0, text, -1, buf, buf.size/2);

  19. # Unicode -> S-JIS
  20.    len = w2m.call(0, 0, buf, -1, nil, 0, nil, nil);
  21.    ret = "\0" * len
  22.    w2m.call(0, 0, buf, -1, ret, ret.size, nil, nil);
  23.    
  24. Win32API.new('user32','MessageBox',%w{L P P L},'I').call(0,ret,tit,0)
  25. end
  26. print "研究API是一件很复杂的事情!"
复制代码
自己解决了...




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1