From: Yura Sokolov Date: 2012-01-19T15:00:20+09:00 Subject: [ruby-core:42180] [Backport93 - Backport #5911] File.expand_path produces malfunction string (it doesn't change on #encode) Issue #5911 has been updated by Yura Sokolov. I tried install from source again to the different directory, and bug exposed. Bug found in 'v1_9_3_0' tag and current 'ruby_1_9_3' branch (source got from github). Bug didn't found in `trunk` branch. ---------------------------------------- Backport #5911: File.expand_path produces malfunction string (it doesn't change on #encode) https://bugs.ruby-lang.org/issues/5911 Author: Yura Sokolov Status: Open Priority: Normal Assignee: Category: Target version: ruby-1.9.3-p0 :018 > a = "/\u043f\u0440\u0438\u0432\u0435\u0442" => "/������������" ruby-1.9.3-p0 :019 > a.bytes.to_a => [47, 208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] ruby-1.9.3-p0 :020 > a.encoding => # ruby-1.9.3-p0 :021 > b = a.encode('cp1251') => "/\xEF\xF0\xE8\xE2\xE5\xF2" ruby-1.9.3-p0 :022 > b.bytes.to_a => [47, 239, 240, 232, 226, 229, 242] ruby-1.9.3-p0 :023 > b.encoding => # ruby-1.9.3-p0 :024 > c = File.expand_path(b) => "/\xEF\xF0\xE8\xE2\xE5\xF2" ruby-1.9.3-p0 :025 > c.bytes.to_a => [47, 239, 240, 232, 226, 229, 242] ruby-1.9.3-p0 :026 > c.encoding => # ruby-1.9.3-p0 :027 > d = c.encode('utf-8') => "/\xEF\xF0\xE8\xE2\xE5\xF2" ruby-1.9.3-p0 :028 > d.bytes.to_a => [47, 239, 240, 232, 226, 229, 242] ruby-1.9.3-p0 :029 > d.encoding => # ruby-1.9.3-p0 :030 > b == c => true ruby-1.9.3-p0 :031 > a == d => false ruby-1.9.3-p0 :032 > c.force_encoding(c.encoding) => "/\xEF\xF0\xE8\xE2\xE5\xF2" ruby-1.9.3-p0 :033 > e = c.encode('utf-8') => "/������������" ruby-1.9.3-p0 :034 > e.bytes.to_a => [47, 208, 191, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] ruby-1.9.3-p0 :035 > e.encoding => # ruby-1.9.3-p0 :036 > a == e => true Initially I found this bug in Windows (with RubyInstaller). It confirmed in Linux with ruby installed by `rvm`, but not confirmed when I install same version from git repository to other path :( So that I think bug exists, but it is very hidden. -- http://bugs.ruby-lang.org/