cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl with idn works

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Tue, 27 Apr 2004 17:14:46 +0200 (CEST)

On Tue, 27 Apr 2004, Gisle Vanem wrote:

> Which was my reason for setting $CHARSET in idna_init().

I never saw a function like that! If your patch included one I must've lost it
in the process. Sorry!

> IMHO it's better use the charset or code-page the OS it using for character
> input. Windows users should not need to worry about configuring idn/iconv.
> My patch only sets $CHARSET if not already set.

The man page for stringprep_locale_charset() says:

       The function respect the
       CHARSET environment variable, but typically uses nl_lang­
       info(CODESET) when it is supported. It fall back on
       "ASCII" if CHARSET isn't set and nl_langinfo isn't sup­
       ported or return anything.

It seems the charset it found on my host "ANSI_X3.4-1968" is what is commonly
referred to as US-ASCII (according to my nl_langinfo man page).

So, it did the right thing I guess.

> putenv() has only effect for current process, so other programs are
> unaffected. Tell me why this isn't a good idea.

To start with, I think stringprep_locale_charset() should do right, otherwise
it is a bug in the code or in the docs.

But other than that, I think your code can be used for Windows. putenv() is
not safe to be used like that in portable manner.

Here's a quote from the putenv man page:

       The libc4 and libc5 and glibc 2.1.2 versions conform to
       SUSv2: the pointer string given to putenv() is used. In
       particular, this string becomes part of the environment;
       changing it later will change the environment. (Thus, it
       is an error is to call putenv() with an automatic variable
       as the argument, then return from the calling function
       while string is still part of the environment.)

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-04-27