相关疑难解决方法(0)

使用ruby 1.9.3的iconv弃用警告

当我运行rspec时,我收到此警告:

/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require': iconv will be deprecated in the future, use String#encode instead.

我与轨道相同的警告3.1.0,3.1.1,3.1.2.rc2版本.似乎它与sqlite3宝石有关,但我不确定.ruby 1.9.2没有警告

有什么建议怎么处理吗?

ruby rspec ruby-on-rails

35
推荐指数
4
解决办法
2万
查看次数

Prawn :: Errors :: IncompatibleStringEncoding:您的文档包含与Windows-1252字符集不兼容的文本

下面是我的Prawn PDF文件,用于在PDF上生成名称 -

def initialize(opportunity_application)
  pdf = Prawn::Document.new(:page_size => [1536, 2048], :page_layout => :landscape)
  cell_1 = pdf.make_cell(content: "Eylül Çamc?".force_encoding('iso-8859-1').encode('utf-8'), borders: [], size: 66, :text_color => "000000", padding: [0,0,0,700], font: "app/assets/fonts/opensans.ttf")

  t = pdf.make_table [[cell_1]]
  t.draw
  pdf.render_file "tmp/mos_certificates/application_test.pdf"
end
Run Code Online (Sandbox Code Playgroud)

当呈现土耳其语名称EylülÇamcı时,我收到以下错误 -

Prawn::Errors::IncompatibleStringEncoding: Your document includes text that's not compatible with the Windows-1252 character set.
If you need full UTF-8 support, use TTF fonts instead of PDF's built-in fonts.
Run Code Online (Sandbox Code Playgroud)

我已经使用支持该名称中字符的TTF字体,我该怎么做才能正确打印名称?

pdf fonts ruby-on-rails utf-8 prawn

23
推荐指数
2
解决办法
2312
查看次数

Mysql2 ::错误:土耳其字符的字符串值不正确

在使用Ruby 2.0的Rails 4.0应用程序中,土耳其语字符在尝试在数据库中插入记录时导致以下ActiveRecord/MySQL错误.有问题的字符例如是ğ和ş,但是ü或Ç(也似乎发生在拉丁字符集中)没有问题.

ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: 
                               '\xC4\x9Fu\xC5\x9F ...' for column ...
Run Code Online (Sandbox Code Playgroud)

你如何防止这个错误?应用程序和数据库使用UTF-8作为标准编码."xC4\x9F"是"ğ"的UTF-8编码,"\ xC5\x9F"是"ş"的UTF-8.两者似乎都是有问题的特殊人物.德语(äöü)或法语(áàâ)特殊字符没有问题.与ISO 8859-1或ISO 8859-15(仅ISO 8859-9支持所有土耳其语字符)相反,应该可以以UTF-8存储土耳其语字符.

数据库的MySQL集合设置如下.切换collection_database到不同的值是否有帮助,例如utf8_unicode_ci

mysql> show variables like '%collation%';
+----------------------+-------------------+
| Variable_name        | Value             |
+----------------------+-------------------+
| collation_connection | utf8_general_ci   |
| collation_database   | latin1_swedish_ci |
| collation_server     | latin1_swedish_ci |
+----------------------+-------------------+
Run Code Online (Sandbox Code Playgroud)

mysql ruby-on-rails utf-8 ruby-2.0 ruby-on-rails-4

10
推荐指数
1
解决办法
4433
查看次数

标签 统计

ruby-on-rails ×3

utf-8 ×2

fonts ×1

mysql ×1

pdf ×1

prawn ×1

rspec ×1

ruby ×1

ruby-2.0 ×1

ruby-on-rails-4 ×1