2011-11-21 96 views
2

我試圖升級一些測試,因爲我們將應用程序從1.8.7的Rails 2移動到Ruby 1.9.2的Rails 3。測試基本上確保數據庫對象可以用unicode字符命名,以提供國際支持。Ruby 1.9,Rails 3和Unicode:代碼將無法識別Unicode字符

測試基本上是這樣的:

#encoding: utf-8 
'ä' =~ /\S/ # this passes 
'ä' =~ \/w/ # this fails, apparently passed on 1.8.7 
model = Model.create!(:name => '§äè®') # this causes a "Name must include at least one letter or number" validation error, which means Ruby (or Rails) is seeing the name as being blank 

這一切根本基礎和非常簡化了張貼在這裏的目的,但這些都是失敗。還有什麼我需要在這裏看?我知道Ruby不能很好地使用Unicode,但這幾乎必須留在。任何幫助表示讚賞。

回答