From: Brian Candler Date: 2010-10-21T04:04:49+09:00 Subject: Re: from where is coming __CF_USER_TEXT_ENCODING ? =?ISO-8859-1?Q?Une_B=E9vue?= wrote in post #955862: > could that explain the fact that when running a script via sudo i do > have to force encoding ie : > File.open(MACSOUP_SIGNATURES_FILE,:encoding => "UTF-8") > > and no need for ":encoding => "UTF-8"" when running as user. If you want the long answer to that question, see http://github.com/candlerb/string19/blob/master/string19.rb The short answer is: (1) Ruby's behaviour when dealing with strings read from files is influenced by the contents of environment variables, unless you explicitly tell it otherwise; and (2) sudo clears out environment variables, unless you explicitly tell it otherwise. > and notice that in both cases i do have : > LANG => fr_FR.UTF-8 The rules for locale setting are complex, and there are other environment variables such as LC_ALL which take precedence over it. See 'man setlocale' -- Posted via http://www.ruby-forum.com/.