gpt4 book ai didi

ruby `encode' : "\xC3"从 ASCII-8BIT 到 UTF-8 (Encoding::UndefinedConversionError)

转载 作者:数据小太阳 更新时间:2023-10-29 06:25:14 29 4
gpt4 key购买 nike

tvdb 中的汉尼拔剧集里有奇怪的角色。

例如:

Œuf

于是ruby吐出:

./manifesto.rb:19:in `encode': "\xC3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
from ./manifesto.rb:19:in `to_json'
from ./manifesto.rb:19:in `<main>'

第 19 行是:

puts @tree.to_json

有没有办法处理这些非utf字符?我宁愿不替换它们,而是转换它们?还是无视他们?我不知道,感谢任何帮助。

奇怪的是脚本通过 cron 运行良好。手动运行它会产生错误。

最佳答案

File.open(yml_file, 'w') 应该改为 File.open(yml_file, 'wb')

关于ruby `encode' : "\xC3"从 ASCII-8BIT 到 UTF-8 (Encoding::UndefinedConversionError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23309669/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com