⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (761 Bytes)
Bug #9016
» encoding-lying-reduced.rb
renatosilva (Renato Silva)
, 10/14/2013 06:57 PM
# Encoding: UTF-8
if
ARGV
[
0
]
==
nil
or
ARGV
[
0
].
encoding
!=
Encoding
::
CP850
puts
"Please run me from cmd.exe after
\"
chcp 850
\"
, and pass me"
puts
"a lowercase a-tilde (http://en.wikipedia.org/wiki/%C3%83)."
exit
end
puts
"Encoding of argument is reported as
#{
ARGV
[
0
].
encoding
}
and as
#{
ARGV
[
0
].
valid_encoding?
?
"valid"
:
"invalid"
}
."
puts
"Let us inspect the a-tilde argument:
#{
ARGV
[
0
].
dump
}
"
puts
"Let us inspect the a-tilde from UTF-8 source code transcoded into CP850:
#{
"ã"
.
encode
(
"CP850"
).
dump
}
"
puts
"Let us inspect the a-tilde from UTF-8 source code transcoded into ISO-8859-1:
#{
"ã"
.
encode
(
"ISO-8859-1"
).
dump
}
"
puts
"RESULT: as you can see, the argument looks like an ISO-8859-1 string, but reports its encoding as CP850."
« Previous
1
2
Next »
(2-2/2)
Loading...