Project1

标题: 路径编码问题 [打印本页]

作者: wbsy8241    时间: 2012-11-23 19:35
标题: 路径编码问题
本帖最后由 wbsy8241 于 2012-11-24 19:47 编辑
  1. #请放桌面测试
  2. class String
  3.   M2W = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  4.   W2M = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  5.   def to_u
  6.     i = M2W.call(0, 0, self, -1, nil, 0)
  7.     buf = "\0" * i * 2
  8.     M2W.call(0, 0, self, -1, buf, i)
  9.     i = W2M.call(65001, 0, buf, -1, nil, 0, nil, nil)
  10.     ret = "\0" * i
  11.     W2M.call(65001, 0, buf, -1, ret, i, nil, nil)
  12.     return ret
  13.   end
  14.   def to_a
  15.     i = M2W.call(65001, 0 , self, -1,nil,0)
  16.     buf = "\0" * i * 2
  17.     M2W.call(65001, 0 , self, -1, buf, i)
  18.     i = W2M.call(0, 0, buf, -1, nil, 0, nil, nil)
  19.     ret = "\0" * i
  20.     W2M.call(0, 0, buf, -1, ret, i, nil, nil)
  21.     return ret
  22.   end
  23. end

  24. a = Dir.getwd
  25. b = a.to_u
  26. c = b.to_a
  27. msgbox_p a
  28. msgbox_p b
  29. msgbox_p c
  30. save_data(a, a)
复制代码
用古老的转码脚本转码后
save_data
load_data
还是不能支持中文路径



自己已通过非转码的方式 读取中文路径下文件了.




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