Console codepage setting via chcp?

Corinna Vinschen
Fri Sep 25 15:36:00 GMT 2009

On Sep 25 16:10, Corinna Vinschen wrote:
> On Sep 25 12:13, Andy Koppe wrote:
> > 2009/9/25 Corinna Vinschen:
> > >> The important thing is that file names, user names, and env variables
> > >> are represented by the same byte sequences throughout the life of a
> > >> program. Determining their translation at program startup ensures
> > >> that.
> > >
> > > But that's not the only important point.  If two applications having
> > > different locales talk to each other, they have different ideas of the
> > > filenames.  Even their CWD could look different, even though it's
> > > actually the same.
> > 
> > True. However, the environment locale setting is constant throughout a
> > process tree unless the user explicitly changes it.
> > 
> > This is different from the issue with filenames depending on whether
> > setlocale is called, because that's outside the user's control.
> The problem is that processes don't just open files, they inherit files
> through the exec call.  So, if the file got opened in the parent process
> (a shell, for instance), then the parent process forks, changes the
> locale var, and execs the child process with a different locale (that's
> what happens when you start nano as in your example given a few mails
> back), then the filenames stored in the fhandlers in the child
> process are using the wrong charset, and subsequent calls using that
> filename are wrong.
> This *might* be a pathological case, given that Cygwin uses the native
> NT name of the file which is stored in the fhandler as UTF-16 string.
> However, I'm not sure that this is really always the case, so we would
> have to expect breakage.

Some of the definitely affected calls are the "at" calls: openat,
fchmodat, unlinkat, etc.  Since we don't have real support for directory
relative pathnames yet, all these function construct the filename by
attaching the path to the POSIX path of the given parent directory and
then call the appropriate non-"at" base function.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-developers mailing list