delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/08/03:02:45

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Subject: codepage translation of environment
Sensitivity:
To: cygwin AT cygwin DOT com
Message-ID: <OFDC632487.742B6E7F-ONC1256FBE.002A6E9D-C1256FBE.002C178A@arburg.com>
From: Heiko_Elger AT arburg DOT com
Date: Tue, 8 Mar 2005 09:01:36 +0100
MIME-Version: 1.0
X-OriginalArrivalTime: 08 Mar 2005 08:01:34.0570 (UTC) FILETIME=[0BE77CA0:01C523B5]
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id j2882fXt023885




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 AT arburg DOT com
http://www.arburg.com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019