Skip to content

Commit

Permalink
Default Windows filesystem encoding to UTF-8
Browse files Browse the repository at this point in the history
This change was applied to CRuby in 3.0.

See https://bugs.ruby-lang.org/issues/12654

Fixes jruby#7750
  • Loading branch information
headius committed Jun 28, 2024
1 parent 6655bb6 commit c9b3e3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jcodings.specific.USASCIIEncoding;
import org.jruby.RubyString;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.cli.Options;
import org.jruby.util.io.EncodingUtils;

public final class EncodingService {
Expand Down Expand Up @@ -430,7 +431,7 @@ private void checkAsciiEncodingName(ByteList name) {
}

public Encoding getWindowsFilesystemEncoding(Ruby ruby) {
String encoding = SafePropertyAccessor.getProperty("file.encoding", "UTF-8");
String encoding = Options.WINDOWS_FILESYSTEM_ENCODING.load();
Encoding filesystemEncoding = loadEncoding(ByteList.create(encoding));

// Use default external if file.encoding does not point at an encoding we recognize
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public class Options {
public static final Option<Boolean> PACKED_ARRAYS = bool(MISCELLANEOUS, "packed.arrays", true, "Toggle whether to use \"packed\" arrays for small tuples.");
public static final Option<Boolean> REGEXP_INTERRUPTIBLE = bool(MISCELLANEOUS, "regexp.interruptible", true, "Allow regexp operations to be interruptible from Ruby.");
public static final Option<Integer> JAR_CACHE_EXPIRATION = integer(MISCELLANEOUS, "jar.cache.expiration", 750, "The time (ms) between checks if a JAR file containing resources has been updated.");
public static final Option<String> WINDOWS_FILESYSTEM_ENCODING = string(MISCELLANEOUS, "windows.filesystem.encoding", "UTF-8", "The encoding to use for filesystem names and paths on Windows.");

public static final Option<Boolean> DEBUG_LOADSERVICE = bool(DEBUG, "debug.loadService", false, "Log require/load file searches.");
public static final Option<Boolean> DEBUG_LOADSERVICE_TIMING = bool(DEBUG, "debug.loadService.timing", false, "Log require/load parse+evaluate times.");
Expand Down

0 comments on commit c9b3e3a

Please sign in to comment.