Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby PG连接转换器错误_Ruby_Postgresql - Fatal编程技术网

Ruby PG连接转换器错误

Ruby PG连接转换器错误,ruby,postgresql,Ruby,Postgresql,当我试图通过pg ruby gem建立到我的Postgres数据库的连接时,我得到以下错误(在初始化连接时): 我尝试连接的数据库为空,但我遇到以下错误,无法真正找出原因: home/mkrs/.rbenv/versions/2.7.1/lib/ruby/2.7.0/irb.rb:599:in `write': "\\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) 如果我运行Encodin

当我试图通过pg ruby gem建立到我的Postgres数据库的连接时,我得到以下错误(在初始化连接时):

我尝试连接的数据库为空,但我遇到以下错误,无法真正找出原因:

home/mkrs/.rbenv/versions/2.7.1/lib/ruby/2.7.0/irb.rb:599:in `write': "\\xC2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
如果我运行
Encoding.default\u external
我会得到:

=> #<Encoding:UTF-8>
=>#

可能会丢失一些奇怪的字符,但不会出现错误。

初始化中,您的意思可能是
@conn=..
,否则您只会创建一个局部变量并将其丢弃。
=> #<Encoding:UTF-8>
str.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')