新手问题 2.7.1 string.encode 参数不正确

cre16yu · August 14, 2020 · Last by cre16yu replied at August 14, 2020 · 1232 hits

版本 ruby2.7.1win64

ret = src.encode('utf-8', 'gbk', {:invalid => '', :replace => ''}) 

报错,unknown value for invalid character option,无法科学搜索 是我一个人的问题吗,赶时间写脚本,已退回到 2.6.5

用 2.6.5 版本仍然有问题,可能我环境乱了,正在重新安装 ruby 和 msys

问题大概找到,string.encode 参数好像只能这样写:{:invalid => :replace, :undef => :replace}),不能直接指定:invalid 为具体字符

cre16yu closed this topic. 15 Aug 15:37
You need to Sign in before reply, if you don't have an account, please Sign up first.