Den Saturday 29 March 2008 10.52.38 skrev Jeff King: > On Sat, Mar 29, 2008 at 10:38:48AM +0100, Robin Rosenberg wrote: > > The environment variables are only part of the story. There is a langinfo > > API for this. See I18N::Langinfo(3pm) that knows about those and > > something else. > > > > # perl -e 'require I18N::Langinfo; I18N::Langinfo->import(qw(langinfo > > CODESET)); $codeset = langinfo(CODESET()); print "My codeset=". > > $codeset."\n";' > > My codeset=ISO-8859-15 > > Hmm, neat. So perhaps it would make sense to just use this value instead > of utf-8, and not worry about examining the actual text (since any such > examination is at best a guess, anyway)? I think you really should try the UTF-8 guess, since a file may well be UTF-8 even if the user locale is something else. Especially for XML files, UTF-8 is common, but there are many more cases. Look into git-gui/po for more examples. The probability of a UTF-8 test being wrong is just so unimaginable low. > PS Your 'require' is more simply written as 'use I18N::Langinfo > qw(langinfo CODESET)', or perhaps even simpler: See the man page, from which I stole it. It suggests you wrap it all inside eval {}, just in case your perl does not have langinfo. As for the is_utf8() i'm not sure what it does, but I can't make it work. -- robin -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html