Skip to content

Commit 62047ba

Browse files
committed
Some fixes for LANG=POSIX
1 parent a9c6662 commit 62047ba

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/ruby/truffleruby/core/dir.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def glob(pattern, flags = 0, base: nil, sort: true, &block)
303303

304304
total = matches.size
305305
while index < total
306-
matches[index] = matches[index].encode(enc) unless matches[index].encoding == enc
306+
matches[index] = matches[index].force_encoding(enc) unless matches[index].encoding == enc
307307
index += 1
308308
end
309309
end

src/main/ruby/truffleruby/core/env.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,11 @@ def set_encoding(value)
366366
if Encoding.default_internal && value.ascii_only?
367367
value = value.encode Encoding.default_internal, Encoding::LOCALE
368368
elsif value.encoding != Encoding::LOCALE
369-
value = value.dup.force_encoding(Encoding::LOCALE)
369+
if Encoding::LOCALE == Encoding::US_ASCII && !value.ascii_only?
370+
value = value.b
371+
else
372+
value = value.dup.force_encoding(Encoding::LOCALE)
373+
end
370374
end
371375
value.freeze
372376
end

0 commit comments

Comments
 (0)