ruby 将“\x\x”格式编码为 utf8 字符串或以当前形式存储在 rails postgres 数据库中

ruby encode "\x\x" format to utf8 string or store in rails postgres db in current form

我在 sha256 中创建了一个 solidity contract 并且它 returns

"Y\xED\x90b\x82\xCDz\xCC\xD4\xA2\xD7\x9E\a\xBB\x13-'\xCC\xA2\x1F\x04Kv%!\xB6\xE8\xF8\xE9\xCB \x8B"

然后当尝试在 string 数据类型字段中保存 postgres 时,我得到

ActiveRecord::StatementInvalid (PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8": 0xed 0x90 0x62

railspostgres 按原样存储 转换 的最佳方法是什么到 UTF8 字符串?

看起来该数据应该以 binary 格式存储。