# Encoding and the windows environment, a question

**URL:** <https://www.ruby-forum.com/t/encoding-and-the-windows-environment-a-question/145096>\
**Category:** Ruby\
**Created:** [August 6, 2008, 12:21am UTC](https://www.ruby-forum.com/t/encoding-and-the-windows-environment-a-question/145096 "2008-08-06T00:21:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AD60](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d9b06d/32.png) [@AD60](https://www.ruby-forum.com/u/AD60)\
**Post date:** [August 6, 2008, 12:21am UTC](https://www.ruby-forum.com/t/encoding-and-the-windows-environment-a-question/145096/1 "2008-08-06T00:21:01Z")

</div>

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
