File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
lib/active_support/multibyte Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,10 @@ class Chars
55
55
# Creates a new Chars instance by wrapping _string_.
56
56
def initialize ( string )
57
57
@wrapped_string = string
58
- @wrapped_string . force_encoding ( Encoding ::UTF_8 ) unless @wrapped_string . frozen?
58
+ if string . encoding != Encoding ::UTF_8
59
+ @wrapped_string = @wrapped_string . dup
60
+ @wrapped_string . force_encoding ( Encoding ::UTF_8 )
61
+ end
59
62
end
60
63
61
64
# Forward all undefined methods to the wrapped string.
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module MultibyteTestHelpers
4
- UNICODE_STRING = "こにちわ"
5
- ASCII_STRING = "ohayo"
6
- BYTE_STRING = ( +"\270 \236 \010 \210 \245 " ) . force_encoding ( "ASCII-8BIT" ) . freeze
4
+ # We use Symbol#to_s to create these strings so warnings are emitted if they are mutated
5
+ UNICODE_STRING = :"こにちわ" . to_s
6
+ ASCII_STRING = :"ohayo" . to_s
7
+ BYTE_STRING = "\270 \236 \010 \210 \245 " . b . freeze
7
8
8
9
def chars ( str )
9
10
ActiveSupport ::Multibyte ::Chars . new ( str )
You can’t perform that action at this time.
0 commit comments