じ☆ve冰风 发表于 2024-4-19 22:43:00

【不是创意的创意】解决调用环境变量中文乱码现象

精灵在汉化游戏的时候,发现一些使用中文用户名的游戏无法启动,症状如下:

经检查出问题的脚本如下:
RUBY 代码
# Create Path Where Folder Should Be Created
path = " " * 256
path = ENV['AV_APPDATA'].rstrip
$appPath = path.to_s + "\\To the Moon - Freebird Games"   

# Create Your Folder
if !File.exists?($appPath)
    Dir.mkdir($appPath)#出问题的那行
end

于是就麻烦了。
中文用户名导致EV['AV_APPDATA']产生乱码,以至于后面的建立文件夹失败。
所以就需要进行S2U转换一下。
解决脚本如下:
RUBY 代码
#Using for Non-english speaking words encoding conversion
#quintess non-english paths
APPNAME = "\\To the Moon - Freebird Games"
module Seiran20
module_function
class ::Integer; def to_ptr; self; end; def to_param; 'i'; end; def ord; self; end; end
class ::String;def to_ptr; .pack('p').unpack('L').first; end; def to_param; 'p'; end; end

def procname(a, b)
    class
页: [1]
查看完整版本: 【不是创意的创意】解决调用环境变量中文乱码现象