Skip to content

Commit e0c0722

Browse files
committed
The default output encoding is now UTF-8. Fixes ruby#106
1 parent 51da5f1 commit e0c0722

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

History.rdoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
=== 3.13
1+
=== 4.0
2+
3+
* Breaking changes
4+
* The default output encoding for RDoc is now UTF-8. Previously RDoc used
5+
the default external encoding which was determined from your locale.
6+
Issue #106 by Justin Baker.
27

38
* Minor enhancements
49
* Added Markdown as a supported format. The markdown format can be set on a

lib/rdoc/options.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ class RDoc::Options
134134
attr_accessor :dry_run
135135

136136
##
137-
# Encoding of output where. This is set via --encoding.
137+
# The output encoding. All input files will be transcoded to this encoding.
138+
#
139+
# The default encoding is UTF-8. This is set via --encoding.
138140

139141
attr_accessor :encoding
140142

@@ -316,8 +318,8 @@ def init_ivars # :nodoc:
316318
@write_options = false
317319

318320
if Object.const_defined? :Encoding then
319-
@encoding = Encoding.default_external
320-
@charset = @encoding.to_s
321+
@encoding = Encoding::UTF_8
322+
@charset = @encoding.name
321323
else
322324
@encoding = nil
323325
@charset = 'UTF-8'
@@ -590,9 +592,10 @@ def parse argv
590592
opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
591593
"Specifies the output encoding. All files",
592594
"read will be converted to this encoding.",
593-
"Preferred over --charset") do |value|
595+
"The default encoding is UTF-8.",
596+
"--encoding is preferred over --charset") do |value|
594597
@encoding = Encoding.find value
595-
@charset = @encoding.to_s # may not be valid value
598+
@charset = @encoding.name # may not be valid value
596599
end
597600

598601
opt.separator nil

test/test_rdoc_options.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,9 @@ class << coder; alias add []=; end
6666

6767
@options.encode_with coder
6868

69-
if Object.const_defined?(:Encoding) then
70-
charset = encoding = Encoding.default_external.name
71-
else
72-
charset = 'UTF-8'
73-
encoding = nil
74-
end
75-
7669
expected = {
77-
'charset' => charset,
78-
'encoding' => encoding,
70+
'charset' => 'UTF-8',
71+
'encoding' => 'UTF-8',
7972
'exclude' => [],
8073
'hyperlink_all' => false,
8174
'line_numbers' => false,
@@ -129,7 +122,7 @@ class << coder; alias add []=; end
129122
def test_encoding_default
130123
skip "Encoding not implemented" unless Object.const_defined? :Encoding
131124

132-
assert_equal Encoding.default_external, @options.encoding
125+
assert_equal Encoding::UTF_8, @options.encoding
133126
end
134127

135128
def test_generator_descriptions

0 commit comments

Comments
 (0)