Forum: JRuby File.expand_path changes encoding?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2014-06-13 07:19
Hello.  I noticed in windows the following:

>> a =  "C:\\Users\\packrd\\Desktop\\Die drei Br\u00FCder/9.mp4"
=> "C:\\Users\\packrd\\Desktop\\Die drei Br\u00FCder/9.mp4"
>> a.encoding
=> #<Encoding:UTF-8>
>> File.expand_path(a)
=> "C:/Users/packrd/Desktop/Die drei Br\xFCder/9.mp4"
>> File.expand_path(a).encoding
=> #<Encoding:IBM437>

However, in MRI [at least 1.9.3 anyway] it preserves the initial
encoding of UTF-8.  Bug presumably? [I think so, since after converting
encodings I can no longer refer to the filename by that path it's like
it doesn't actually exist...]
This topic is locked and can not be replied to.