cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: setlocale() in curl

From: Peter Wullinger <some-mail-drop_at_gmx.net>
Date: Mon, 18 Oct 2004 13:56:51 +0200

In epistula a Gisle Vanem, die horaque Mon, Oct 18, 2004 at 01:06:33PM +0200:
> "Peter Wullinger" wrote:
>
> >% set | grep -a LC_
> >LC_ALL=de_DE.UTF-8
> >
> >GNU libidn seems to pick up the source encoding for the
> >domain name from nl_langinfo(), which in turn calls
> >setlocale() on FreeBSD.
>
> Or it picks it up from env-var CHARSET. On Windows
> "set CHARSET=cp1253" works here for your url:

It does that here, too, and that is afaict documented behaviour:

-- Function: const char * stringprep_locale_charset ( VOID)
        Find out current locale charset. The function respect the CHARSET
        environment variable, but typically uses nl_langinfo(CODESET) when
        it is supported. It fall back on "ASCII" if CHARSET isn't set and
        nl_langinfo isn't supported or return anything.

Thanks for pointing this out.

My (implied) question actually was: How should curl behave?

I personally think, it should pick up LC_*-information, if possible,
making it consistent with other applications.

Setting “CHARSET” will still work, though:

% echo $LC_ALL
de_DE.UTF-8
% curl -v http://%c3%b6%c3%a4%c3%bc.com/
* Couldn't find host öäü.com in the .netrc file, using defaults
* Input domain encoded as `UTF-8'
* About to connect() to xn--4ca9at.com port 80

% export CHARSET=ISO8859-15
% curl -v http://%c3%b6%c3%a4%c3%bc.com/
* Couldn't find host öäü.com in the .netrc file, using defaults
* Input domain encoded as `ISO8859-15'
* getaddrinfo(3) failed for xn--tba3gba47cu81m.com:80

I also do not think, this rises some portability issues, since a
system having nl_langinfo() is bound to have setlocale(), too, is it?

If nobody objects, I probably should push this as a bug (say feature
enhancement).

>
> The document has moved here

*headscratching* That domain really has content? I was just choosing
it, since these letters are the only meaningful (besides the paragraph
sign) non-ascii characters on my keyboard.

Greets,
        Peter

-- 
Die Geschichte lehrt die Menschen, daß die Geschichte die Menschen
nichts lehrt.
	-- Mahatma Gandhi
Received on 2004-10-18