Contrary to established wisdom I named my user on my windows (Vista)
system “André” (with an e-acute). It is my name after all. The
Dir.glob method shows my home directory using ISO-8859-15 encoding.
The thing that puzzles me is that when I request my home directory
from the environment I have to convert from codepage 850. Why are two
different methods of encoding used when requesting more or less the
same information from the operating system?
This program shows what I mean:
require ‘iconv’
puts “See my user directory here:”
p Dir.glob("/Users/*")
puts “Now look at the environment:”
a = ENV[“HOMEPATH”]
p a
puts a
puts “To get it right:”
converter = Iconv.new(‘ISO-8859-15’, ‘CP850’)
b = converter.iconv(a)
p b
puts b
OUTPUT:
See my user directory here:
["/Users/Andr\351", “/Users/Chantal”, “/Users/Default”, “/Users/
desktop.ini”, “/Users/Public”]
Now look at the environment:
“\Users\Andr\202”
\Users\Andr‚
To get it right:
“\Users\Andr\351”
\Users\Andr