Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2c471b3a
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2c471b3a
编写于
12月 08, 2011
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
load the encoding converter to work around [ruby-core:41556] when switching encodings
上级
8c26cd5d
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
115 deletion
+1
-115
actionpack/lib/action_view/data/encoding_conversions.txt
actionpack/lib/action_view/data/encoding_conversions.txt
+0
-88
actionpack/lib/action_view/template.rb
actionpack/lib/action_view/template.rb
+0
-27
actionpack/test/template/template_test.rb
actionpack/test/template/template_test.rb
+1
-0
未找到文件。
actionpack/lib/action_view/data/encoding_conversions.txt
已删除
100644 → 0
浏览文件 @
8c26cd5d
此差异已折叠。
点击以展开。
actionpack/lib/action_view/template.rb
浏览文件 @
2c471b3a
...
...
@@ -3,33 +3,6 @@
require
'active_support/core_ext/object/try'
require
'active_support/core_ext/kernel/singleton_class'
if
defined?
(
RUBY_ENGINE
)
&&
RUBY_ENGINE
==
'ruby'
&&
RUBY_VERSION
==
'1.9.3'
&&
RUBY_PATCHLEVEL
==
0
# This is a hack to work around a bug in Ruby 1.9.3p0:
# http://redmine.ruby-lang.org/issues/5564
#
# Basically, at runtime we may need to perform some encoding conversions on the templates,
# but if the converter hasn't been loaded by Ruby beforehand (i.e. now), then it won't be
# able to find it (due to a bug).
#
# However, we don't know what conversions we may need to do a runtime. So we load up a
# text file which contains a pre-generated list of all the possible conversions,
# and we load all of them.
#
# In my testing this increased the process size by about 3.9 MB (after the conversions array
# is GC'd) and took around 170ms to run, which seems acceptable for a workaround.
#
# The script to dump the conversions is: https://gist.github.com/1371499
filename
=
File
.
join
(
File
.
dirname
(
__FILE__
),
'data'
,
'encoding_conversions.txt'
)
conversions
=
File
.
read
(
filename
)
conversions
.
split
(
"
\n
"
).
map
do
|
line
|
from
,
to_array
=
line
.
split
(
':'
)
to_array
.
split
(
','
).
each
do
|
to
|
Encoding
::
Converter
.
new
(
from
,
to
)
end
end
end
module
ActionView
# = Action View Template
class
Template
...
...
actionpack/test/template/template_test.rb
浏览文件 @
2c471b3a
...
...
@@ -170,6 +170,7 @@ def test_error_when_template_isnt_valid_utf8
def
with_external_encoding
(
encoding
)
old
=
Encoding
.
default_external
Encoding
::
Converter
.
new
old
,
encoding
silence_warnings
{
Encoding
.
default_external
=
encoding
}
yield
ensure
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录