File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ module CodesetUtil
5
5
6
6
def self . replace_invalid_utf8 ( str )
7
7
return nil if str . nil?
8
+
8
9
str = str . dup
9
10
str . force_encoding ( 'UTF-8' )
10
11
if ! str . valid_encoding?
@@ -16,6 +17,7 @@ def self.replace_invalid_utf8(str)
16
17
17
18
def self . to_utf8 ( str , encoding )
18
19
return if str . nil?
20
+
19
21
str = str . b
20
22
if str . empty?
21
23
str . force_encoding ( "UTF-8" )
@@ -34,15 +36,18 @@ def self.to_utf8(str, encoding)
34
36
35
37
def self . to_utf8_by_setting ( str )
36
38
return if str . nil?
39
+
37
40
str = str . dup
38
41
self . to_utf8_by_setting_internal ( str ) . force_encoding ( 'UTF-8' )
39
42
end
40
43
41
44
def self . to_utf8_by_setting_internal ( str )
42
45
return if str . nil?
46
+
43
47
str = str . b
44
48
return str if str . empty?
45
49
return str if /\A [\r \n \t \x20 -\x7e ]*\Z /n . match? ( str ) # for us-ascii
50
+
46
51
str . force_encoding ( 'UTF-8' )
47
52
encodings = Setting . repositories_encodings . split ( ',' ) . collect ( &:strip )
48
53
encodings . each do |encoding |
@@ -59,6 +64,7 @@ def self.to_utf8_by_setting_internal(str)
59
64
60
65
def self . from_utf8 ( str , encoding )
61
66
return if str . nil?
67
+
62
68
str = str . dup
63
69
str ||= ''
64
70
str . force_encoding ( 'UTF-8' )
You can’t perform that action at this time.
0 commit comments