[#13161] hacking on the "heap" implementation in gc.c — Lloyd Hilaiel <lloyd@...>

Hi all,

16 messages 2007/11/01

[#13182] Thinking of dropping YAML from 1.8 — Urabe Shyouhei <shyouhei@...>

Hello all.

14 messages 2007/11/03

[#13315] primary encoding and source encoding — David Flanagan <david@...>

I've got a couple of questions about the handling of primary encoding.

29 messages 2007/11/08
[#13331] Re: primary encoding and source encoding — Yukihiro Matsumoto <matz@...> 2007/11/09

Hi,

[#13368] method names in 1.9 — "David A. Black" <dblack@...>

Hi --

61 messages 2007/11/10
[#13369] Re: method names in 1.9 — Yukihiro Matsumoto <matz@...> 2007/11/10

Hi,

[#13388] Re: method names in 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

Yukihiro Matsumoto wrote:

[#13403] Re: method names in 1.9 — "Austin Ziegler" <halostatue@...> 2007/11/11

On 11/11/07, Charles Oliver Nutter <charles.nutter@sun.com> wrote:

[#13410] Re: method names in 1.9 — David Flanagan <david@...> 2007/11/11

Austin Ziegler wrote:

[#13413] Re: method names in 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

David Flanagan wrote:

[#13423] Re: method names in 1.9 — Jordi <mumismo@...> 2007/11/12

Summing it up:

[#13386] Re: method names in 1.9 — Trans <transfire@...> 2007/11/11

[#13391] Re: method names in 1.9 — Matthew Boeh <mboeh@...> 2007/11/11

On Sun, Nov 11, 2007 at 05:50:18PM +0900, Trans wrote:

[#13457] mingw rename — "Roger Pack" <rogerpack2005@...>

Currently for different windows' builds, the names for RUBY_PLATFORM

13 messages 2007/11/13

[#13485] Proposal: Array#walker — Wolfgang Nádasi-Donner <ed.odanow@...>

Good morning all together!

23 messages 2007/11/14
[#13486] Re: Proposal: Array#walker — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/11/14

A nicer version may be...

[#13488] Re: Proposal: Array#walker — Trans <transfire@...> 2007/11/14

[#13495] Re: Proposal: Array#walker — Trans <transfire@...> 2007/11/14

[#13498] state of threads in 1.9 — Jordi <mumismo@...>

Are Threads mapped to threads on the underlying operating system in

30 messages 2007/11/14
[#13519] Re: state of threads in 1.9 — "Bill Kelly" <billk@...> 2007/11/14

[#13526] Re: state of threads in 1.9 — Eric Hodel <drbrain@...7.net> 2007/11/14

On Nov 14, 2007, at 11:18 , Bill Kelly wrote:

[#13528] test/unit and miniunit — Ryan Davis <ryand-ruby@...>

When is the 1.9 freeze?

17 messages 2007/11/14

[#13564] Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — Wolfgang Nádasi-Donner <ed.odanow@...>

Good evening all together!

53 messages 2007/11/15
[#13575] Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — "Nikolai Weibull" <now@...> 2007/11/15

On Nov 15, 2007 8:14 PM, Wolfgang N=E1dasi-Donner <ed.odanow@wonado.de> wro=

[#13578] Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — Michael Neumann <mneumann@...> 2007/11/16

Nikolai Weibull schrieb:

[#13598] wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13605] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — Trans <transfire@...> 2007/11/16

[#13612] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13624] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "Nikolai Weibull" <now@...> 2007/11/16

On Nov 16, 2007 12:40 PM, David A. Black <dblack@rubypal.com> wrote:

[#13632] Re: wondering about #tap — David Flanagan <david@...> 2007/11/16

David A. Black wrote:

[#13634] Re: wondering about #tap — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13636] Re: wondering about #tap — "Rick DeNatale" <rick.denatale@...> 2007/11/16

On Nov 16, 2007 12:40 PM, David A. Black <dblack@rubypal.com> wrote:

[#13637] Re: wondering about #tap — murphy <murphy@...> 2007/11/16

Rick DeNatale wrote:

[#13640] Re: wondering about #tap — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/11/16

murphy schrieb:

[#13614] Suggestion for native thread tests — "Eust痃uio Rangel" <eustaquiorangel@...>

Hi!

12 messages 2007/11/16

[#13685] Problems with \M-x in utf-8 encoded strings — Wolfgang Nádasi-Donner <ed.odanow@...>

Hi!

11 messages 2007/11/18

[#13741] retry semantics changed — Dave Thomas <dave@...>

In 1.8, I could write:

46 messages 2007/11/23
[#13742] Re: retry semantics changed — "Brian Mitchell" <binary42@...> 2007/11/23

On Nov 23, 2007 12:06 PM, Dave Thomas <dave@pragprog.com> wrote:

[#13743] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[#13746] Re: retry semantics changed — Yukihiro Matsumoto <matz@...> 2007/11/23

Hi,

[#13747] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[#13748] Re: retry semantics changed — Yukihiro Matsumoto <matz@...> 2007/11/23

Hi,

[#13749] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

Re: primary encoding and source encoding

From: David Flanagan <david@...>
Date: 2007-11-09 07:08:02 UTC
List: ruby-core #13326
Nobuyoshi Nakada wrote:
> Hi,
> 
> At Fri, 9 Nov 2007 05:42:47 +0900,
> David Flanagan wrote in [ruby-core:13315]:
>> Q1) In step 1 above, should the default primary encoding come from the 
>> locale environment variables (LC_ALL, LC_CTYPE, and LANG) instead of 
>> defaulting to ASCII?
> 
> It's planned, but we have no mappings from locale name to
> encoding name.  Attached is a quick hack I tried the week
> before last.

Did you consider nl_langinfo(CODESET)?  Your code looks good to me, 
except that you don't check LC_CTYPE.  Is it your intent to be 
conservative and assume ASCII unless the locale explicitly specifies an 
encoding name following a .?  You're not going to choose either EUC-JP 
or SJIS as the default for Japanese locales?

The public-domain code at http://www.cl.cam.ac.uk/~mgk25/ucs/langinfo.c 
might be useful if you want to be more liberal about guessing encodings 
based on language codes.

>> Q2) If yes, to the above, then shouldn't we drop step 5 above?  If my 
>> locale specifies UTF-8 as my primary encoding then I don't think that 
>> should be changed just because I run a script developed by a Japanese 
>> programmer and encoded in EUC-JP.
> 
> Yes, I think.

Thanks.

	David

> 
> Index: ruby.c
> ===================================================================
> --- ruby.c	(revision 13847)
> +++ ruby.c	(working copy)
> @@ -133,4 +133,34 @@ usage(const char *name)
>  }
>  
> +static rb_encoding *
> +locale_encoding(void)
> +{
> +    const char *lang = getenv("LC_ALL");
> +    int idx = 0;
> +    rb_encoding *enc;
> +
> +    if (!lang) lang = getenv("LANG");
> +    if (lang && (lang = strchr(lang, '.')) != 0) {
> +	const char *at = strchr(++lang, '@');
> +	int len = (at ? at - lang : strlen(lang));
> +	char buf[32];
> +	if (len < sizeof(buf)) {
> +	    MEMCPY(buf, lang, char, len);
> +	    buf[len] = 0;
> +	    idx = rb_enc_find_index(buf);
> +	    if (idx < 0 && len > 3 &&
> +		(strncasecmp(buf, "euc", 3) == 0 ||
> +		 strncasecmp(buf, "utf", 3) == 0) &&
> +		buf[3]) {
> +		MEMMOVE(buf + 4, buf + 3, char, len - 2);
> +		buf[3] = '-';
> +		idx = rb_enc_find_index(buf);
> +	    }
> +	}
> +    }
> +    enc = rb_enc_from_index(idx);
> +    return enc ? enc : rb_enc_default();
> +}
> +
>  extern VALUE rb_load_path;
>  
> @@ -851,5 +881,5 @@ process_options(VALUE arg)
>      NODE *tree = 0;
>      VALUE parser;
> -    VALUE encoding;
> +    rb_encoding *enc;
>      const char *s;
>      int i = proc_options(argc, argv, opt);
> @@ -980,10 +1010,10 @@ process_options(VALUE arg)
>  
>      if (opt->enc_index >= 0) {
> -	encoding = rb_enc_from_encoding(rb_enc_from_index(opt->enc_index));
> +	enc = rb_enc_from_index(opt->enc_index);
>      }
>      else {
> -	encoding = rb_parser_encoding(parser);
> +	enc = locale_encoding();
>      }
> -    rb_set_primary_encoding(encoding);
> +    rb_set_primary_encoding(rb_enc_from_encoding(enc));
>  
>      return (VALUE)tree;
> 
> 


In This Thread