File.expand_path changes encoding?

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs