This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

codepage translation of environment





Hello all,

why is the environment converted to another codepage!
I'm using newest cygwin version 1.5.13!

Here just an example:

I'm in an standard cmd.exe and set the environment variable ZZ to 1ÃÃÃÃÃÃÃ2
set ZZ=1ÃÃÃÃÃÃÃ2

I did several test using the small program getEnv.exe (source code see below)
The programs are generated like the following:

Create the program using Microsoft Visual C 6
cl /Fe getEnv_vs.exe getEnv.c

Create the program using cygwin
gcc -o getEnv_cygwin getEnv.c

Create the program using cygwin with the -mno-cygwin Option
gcc -mno-cygwin -o getEnv_nocygwin getEnv.c

Here are the different outputs of the test programs - the programs are started
in a cmd.exe!!

C:\MyDevelopment\cygwin\getenv>getEnv_cygwin.exe
Start ............
Start cygwin Version.........
ZZ: <1""?ZTsÃ2>
0x31 (1)0x84 (?)0x94 (?)0x81 (?)0x8e (?)0x99 (?)0x9a (?)0xe1 (?)0x32 (2)
Ende ............

C:\MyDevelopment\cygwin\getenv>getEnv_nocygwin.exe
Start ............
Start cygwin Version.........
ZZ: <1ÃÃÂâÃââ2>
0x31 (1)0xe4 (?)0xf6 (?)0xfc (?)0xc4 (?)0xd6 (?)0xdc (?)0xdf (?)0x32 (2)
Ende ............

C:\MyDevelopment\cygwin\getenv>getEnv_vs.exe
Start ............
Start Microsoft Version.........
ZZ: <1ÃÃÂâÃââ2>
0x31 (1)0xe4 (?)0xf6 (?)0xfc (?)0xc4 (?)0xd6 (?)0xdc (?)0xdf (?)0x32 (2)
Ende ............


so the characters for real cygwin program is always converted

à (umlau a)
-- 0xa4 (cygwin)
-- 0xe4 (non-cygwin, Visual Studio)
à (umlau o)
-- 0x94 (cygwin)
-- 0xf6 (non-cygwin, Visual Studio)


In codepage 1252 (latin1) character 0xe4 represents the umlaut a!!
In codepage 850 character 0xa4 represents the umlaut a!!

Why do cygwin this conversion?

I did some test using the CYGWIN environment variable with codepage:ansi and
codepage:oem!
But the characters are still converted - the codepage affects only the
repesentation on screen but not the characters values!
It's also independet using chcp command and change to 850 and 1252 vice versa!


Please help ...
Any hints are welcome ...

----------------------- getEnv.c program ----------------------
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv, char **env)
{
    char * p_env_name = NULL;
    const char * p_env_value = NULL;
    printf("Start ............\n");
#ifdef _MSC_VER
    printf("Start Microsoft Version.........\n");
#else
    printf("Start cygwin Version.........\n");
#endif
    if (argc!=2)
    {
        p_env_name = "ZZ";
    }
    else
    {
        p_env_name = "argv[1]";
    }

    p_env_value = (const char*) getenv(p_env_name);

    printf("%s: <%s>\n", p_env_name, p_env_value==NULL ? "NULL" : p_env_value);
    if (p_env_value)
    {
        size_t len = strlen(p_env_value);
        size_t i;
        for (i=0;i<len;i++)
        {
            unsigned char ch = (unsigned char)*(p_env_value+i);
            printf("%#02hx (%c)", ch, (ch>=0x20 && ch <=0x80) ? ch : '?');
        }
        printf("\n");
    }
    printf("Ende ............\n");
    return 0;
}
------------------------------------------------------


best regards

   Heiko Elger



********************

ARBURG GmbH + Co
Heiko Elger
- Softwareentwicklung - / - Research and Development -
Arthur-Hehl-Strasse
D-72290 Lossburg
Tel.: +49 (0) 7446 33-3659
Fax.: +49 (0) 7446 33-3365
mailto:heiko_elger@arburg.com
http://www.arburg.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]