From 58ef0f06c6f6fcc4f6a0d31ade430d87ef9d968d Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 6 Nov 2012 00:49:57 +0000 Subject: * ruby.c (load_file_internal): set default source encoding as UTF-8 instead of US-ASCII. [ruby-core:46021] [Feature #6679] * parse.y (parser_initialize): set default parser encoding as UTF-8 instead of US-ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ NEWS | 2 ++ lib/rexml/encoding.rb | 1 + lib/rexml/source.rb | 1 + parse.y | 2 +- ruby.c | 2 +- test/base64/test_base64.rb | 1 + test/dl/test_import.rb | 1 + test/logger/test_logger.rb | 1 + test/net/http/test_http.rb | 3 +-- test/net/http/test_httpresponse.rb | 1 + test/openssl/test_x509name.rb | 1 + test/psych/test_yaml.rb | 2 +- test/psych/visitors/test_to_ruby.rb | 1 + test/ripper/test_ripper.rb | 2 +- test/ruby/test_array.rb | 1 + test/ruby/test_io.rb | 1 + test/ruby/test_io_m17n.rb | 1 + test/ruby/test_m17n.rb | 1 + test/ruby/test_pack.rb | 1 + test/ruby/test_parse.rb | 1 + test/ruby/test_regexp.rb | 1 + test/syslog/test_syslog_logger.rb | 1 + test/webrick/test_cgi.rb | 1 + 24 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cf8f24083..bcad80d32a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Nov 6 09:37:57 2012 NARUSE, Yui + + * ruby.c (load_file_internal): set default source encoding as + UTF-8 instead of US-ASCII. [ruby-core:46021] [Feature #6679] + + * parse.y (parser_initialize): set default parser encoding as + UTF-8 instead of US-ASCII. + Tue Nov 6 05:48:06 2012 Hiroshi Shirosaki * test/ruby/test_require.rb diff --git a/NEWS b/NEWS index 1e31e581bc..df737c447e 100644 --- a/NEWS +++ b/NEWS @@ -248,6 +248,8 @@ with all sufficient information, see the ChangeLog file. * Added %i and %I for symbol list creation (similar to %w and %W). + * Default source encoding is changed to UTF-8. (was US-ASCII) + === Compatibility issues (excluding feature bug fixes) * Signal.trap diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb index 2863af9147..1c7e79a124 100644 --- a/lib/rexml/encoding.rb +++ b/lib/rexml/encoding.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII module REXML module Encoding # ID ---> Encoding name diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb index eec1b6c7e8..b653714b2f 100644 --- a/lib/rexml/source.rb +++ b/lib/rexml/source.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'rexml/encoding' module REXML diff --git a/parse.y b/parse.y index 5f3617556b..e043e99e2e 100644 --- a/parse.y +++ b/parse.y @@ -10580,7 +10580,7 @@ parser_initialize(struct parser_params *parser) #ifdef YYMALLOC parser->heap = NULL; #endif - parser->enc = rb_usascii_encoding(); + parser->enc = rb_utf8_encoding(); } #ifdef RIPPER diff --git a/ruby.c b/ruby.c index df749e0aee..8654f878e4 100644 --- a/ruby.c +++ b/ruby.c @@ -1692,7 +1692,7 @@ load_file_internal(VALUE arg) enc = rb_locale_encoding(); } else { - enc = rb_usascii_encoding(); + enc = rb_utf8_encoding(); } if (NIL_P(f)) { f = rb_str_new(0, 0); diff --git a/test/base64/test_base64.rb b/test/base64/test_base64.rb index 9ae54cb405..c5e61b31ac 100644 --- a/test/base64/test_base64.rb +++ b/test/base64/test_base64.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require "test/unit" require "base64" diff --git a/test/dl/test_import.rb b/test/dl/test_import.rb index 26b9f3c803..41def7c913 100644 --- a/test/dl/test_import.rb +++ b/test/dl/test_import.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require_relative 'test_base' require 'dl/import' diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index 8fc02f8899..100c1ea06d 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require 'logger' require 'tempfile' diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 6a35ca29f1..0dfb462d3b 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -1,5 +1,4 @@ -# $Id$ - +# coding: US-ASCII require 'test/unit' require 'net/http' require 'stringio' diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 70313cc519..a4f242d56e 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'net/http' require 'test/unit' require 'stringio' diff --git a/test/openssl/test_x509name.rb b/test/openssl/test_x509name.rb index 0a223438ba..de35fc303a 100644 --- a/test/openssl/test_x509name.rb +++ b/test/openssl/test_x509name.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require_relative 'utils' if defined?(OpenSSL) diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb index 807c058d2e..796a44fa2b 100644 --- a/test/psych/test_yaml.rb +++ b/test/psych/test_yaml.rb @@ -1,4 +1,4 @@ -# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- +# -*- coding: us-ascii; mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- # vim:sw=4:ts=4 # $Id$ # diff --git a/test/psych/visitors/test_to_ruby.rb b/test/psych/visitors/test_to_ruby.rb index 5b0702cf1a..ee473c9ba2 100644 --- a/test/psych/visitors/test_to_ruby.rb +++ b/test/psych/visitors/test_to_ruby.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'psych/helper' module Psych diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb index 72dc52d087..1d6e8934ef 100644 --- a/test/ripper/test_ripper.rb +++ b/test/ripper/test_ripper.rb @@ -17,7 +17,7 @@ class TestRipper::Ripper < Test::Unit::TestCase end def test_encoding - assert_equal Encoding::US_ASCII, @ripper.encoding + assert_equal Encoding::UTF_8, @ripper.encoding end def test_end_seen_eh diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 845a05089a..b0e7058b5b 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require_relative 'envutil' diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index ddc5f8cb00..d0924844b1 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require 'tmpdir' require "fcntl" diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index b6358e0d92..3cc84374be 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require 'tmpdir' require 'timeout' diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 87563349f7..7e343ab31f 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require_relative 'envutil' diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 1463bd035b..76956ef25f 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' class TestPack < Test::Unit::TestCase diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 8623960b42..319af751d0 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require 'stringio' diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 0825e945fd..de89a67289 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require 'envutil' diff --git a/test/syslog/test_syslog_logger.rb b/test/syslog/test_syslog_logger.rb index 3a659cfb84..f34025ddfd 100644 --- a/test/syslog/test_syslog_logger.rb +++ b/test/syslog/test_syslog_logger.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require 'test/unit' require 'tempfile' begin diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb index 72e3be9aab..d2d54171f8 100644 --- a/test/webrick/test_cgi.rb +++ b/test/webrick/test_cgi.rb @@ -1,3 +1,4 @@ +# coding: US-ASCII require_relative "utils" require "webrick" require "test/unit" -- cgit v1.2.3