Permalink
Browse files

The default output encoding is now UTF-8. Fixes #106

  • Loading branch information...
drbrain committed Apr 13, 2012
1 parent 51da5f1 commit e0c0722a305cc7128ed575b849388de3d1706dad
Showing with 17 additions and 16 deletions.
  1. +6 −1 History.rdoc
  2. +8 −5 lib/rdoc/options.rb
  3. +3 −10 test/test_rdoc_options.rb
View
@@ -1,4 +1,9 @@
-=== 3.13
+=== 4.0
+
+* Breaking changes
+ * The default output encoding for RDoc is now UTF-8. Previously RDoc used
+ the default external encoding which was determined from your locale.
+ Issue #106 by Justin Baker.
* Minor enhancements
* Added Markdown as a supported format. The markdown format can be set on a
View
@@ -134,7 +134,9 @@ class RDoc::Options
attr_accessor :dry_run
##
- # Encoding of output where. This is set via --encoding.
+ # The output encoding. All input files will be transcoded to this encoding.
+ #
+ # The default encoding is UTF-8. This is set via --encoding.
attr_accessor :encoding
@@ -316,8 +318,8 @@ def init_ivars # :nodoc:
@write_options = false
if Object.const_defined? :Encoding then
- @encoding = Encoding.default_external
- @charset = @encoding.to_s
+ @encoding = Encoding::UTF_8
+ @charset = @encoding.name
else
@encoding = nil
@charset = 'UTF-8'
@@ -590,9 +592,10 @@ def parse argv
opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
"Specifies the output encoding. All files",
"read will be converted to this encoding.",
- "Preferred over --charset") do |value|
+ "The default encoding is UTF-8.",
+ "--encoding is preferred over --charset") do |value|
@encoding = Encoding.find value
- @charset = @encoding.to_s # may not be valid value
+ @charset = @encoding.name # may not be valid value
end
opt.separator nil
View
@@ -66,16 +66,9 @@ class << coder; alias add []=; end
@options.encode_with coder
- if Object.const_defined?(:Encoding) then
- charset = encoding = Encoding.default_external.name
- else
- charset = 'UTF-8'
- encoding = nil
- end
-
expected = {
- 'charset' => charset,
- 'encoding' => encoding,
+ 'charset' => 'UTF-8',
+ 'encoding' => 'UTF-8',
'exclude' => [],
'hyperlink_all' => false,
'line_numbers' => false,
@@ -129,7 +122,7 @@ class << coder; alias add []=; end
def test_encoding_default
skip "Encoding not implemented" unless Object.const_defined? :Encoding
- assert_equal Encoding.default_external, @options.encoding
+ assert_equal Encoding::UTF_8, @options.encoding
end
def test_generator_descriptions

0 comments on commit e0c0722

Please sign in to comment.