Encoding and the windows environment, a question.

A

AD60

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é
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top