⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (926 Bytes)
Bug #7267
» test.rb
Test script -
kennygrant (Kenny Grant)
, 11/02/2012 07:54 PM
#!/Users/kenny/.rvm/rubies/ruby-2.0.0-preview1/bin/ruby
#!encoding:UTF-8
def
inspect_string
s
puts
"Source encoding:
#{
""
.
encoding
}
"
puts
"External encoding:
#{
Encoding
.
default_external
}
"
puts
"Name:
#{
s
.
inspect
}
"
puts
"Encoding:
#{
s
.
encoding
}
"
puts
"Chars:
#{
s
.
chars
.
to_a
.
inspect
}
"
puts
"Codepoints:
#{
s
.
codepoints
.
to_a
.
inspect
}
"
puts
"Bytes:
#{
s
.
bytes
.
to_a
.
inspect
}
"
end
def
transform_string
s
puts
"Testing string
#{
s
}
"
puts
s
.
gsub
(
/é/u
,
'TEST'
)
end
Dir
.
glob
(
"./*.txt"
).
each
do
|
f
|
puts
`ruby -v`
puts
"Inline string works as expected"
s
=
"./Testé.txt"
inspect_string
s
puts
transform_string
s
puts
"File name from Dir.glob does not"
inspect_string
f
puts
transform_string
f
puts
"Encoded file name works as expected, though it is reported as UTF-8"
f
.
encode!
(
'UTF-8'
,
'UTF-8-MAC'
)
inspect_string
s
puts
transform_string
f
end
« Previous
1
2
3
4
Next »
(1-1/4)
Loading...