Forum: JRuby File.expand_path changes encoding?

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...]
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.