@@ -6,7 +6,7 module Redmine | |||||
6 | return str if str.nil? |
|
6 | return str if str.nil? | |
7 | str.force_encoding('UTF-8') |
|
7 | str.force_encoding('UTF-8') | |
8 | if ! str.valid_encoding? |
|
8 | if ! str.valid_encoding? | |
9 |
str = str.encode("U |
|
9 | str = str.encode("UTF-16LE", :invalid => :replace, | |
10 | :undef => :replace, :replace => '?').encode("UTF-8") |
|
10 | :undef => :replace, :replace => '?').encode("UTF-8") | |
11 | end |
|
11 | end | |
12 | str |
|
12 | str |
@@ -91,7 +91,7 class Redmine::CodesetUtilTest < ActiveSupport::TestCase | |||||
91 | s2 = Redmine::CodesetUtil.replace_invalid_utf8(s1) |
|
91 | s2 = Redmine::CodesetUtil.replace_invalid_utf8(s1) | |
92 | assert s2.valid_encoding? |
|
92 | assert s2.valid_encoding? | |
93 | assert_equal "UTF-8", s2.encoding.to_s |
|
93 | assert_equal "UTF-8", s2.encoding.to_s | |
94 | assert_equal "??????", s2 |
|
94 | assert_equal "\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1??".force_encoding("UTF-8"), s2 | |
95 | end |
|
95 | end | |
96 |
|
96 | |||
97 | test "#to_utf8 should replace invalid non utf8" do |
|
97 | test "#to_utf8 should replace invalid non utf8" do |
General Comments 0
You need to be logged in to leave comments.
Login now