Actions
Backport #5911
closedFile.expand_path produces malfunction string (it doesn't change on #encode)
Status:
Closed
Assignee:
-
Description
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
=> #<Encoding:UTF-8>
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
=> #<Encoding:Windows-1251>
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
=> #<Encoding:Windows-1251>
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
=> #<Encoding:UTF-8>
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
=> #<Encoding:UTF-8>
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.
Updated by naruse (Yui NARUSE) almost 13 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193
- Category deleted (
core) - Target version deleted (
1.9.3)
r33603 fixes this.
Updated by funny_falcon (Yura Sokolov) almost 13 years ago
I tried install from source again to the different directory, and bug exposed.
Bug had found in 'v1_9_3_0' tag and current 'ruby_1_9_3' branch (source got from github).
Bug hadn't found in trunk
branch.
Updated by funny_falcon (Yura Sokolov) almost 13 years ago
O, sorry, I didn't refresh browser before sending comment.
Updated by naruse (Yui NARUSE) almost 13 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Actions
Like0
Like0Like0Like0Like0