Skip to content

Commit 8d555c9

Browse files
committedSep 11, 2014
Merge pull request #338 from Razer6/preserve_encoding
Force encoding of posix_spawn output
2 parents 589f299 + a183412 commit 8d555c9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎lib/github/markup/command_implementation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def call_block(rendered, content)
3535
def execute(command, target)
3636
spawn = POSIX::Spawn::Child.new(*command, :input => target)
3737
if spawn.status.success?
38-
spawn.out.gsub("\r", '')
38+
spawn.out.gsub("\r", '').force_encoding(target.encoding)
3939
else
4040
raise CommandError.new(spawn.err.strip)
4141
end

‎test/markup_test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# encoding: UTF-8
2+
13
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
24

35
require 'github/markup'
@@ -50,4 +52,9 @@ def test_raises_error_if_command_exits_non_zero
5052
fail "an exception was expected but was not raised"
5153
end
5254
end
55+
56+
def test_preserve_markup
57+
content = "Noël"
58+
assert_equal content.encoding.name, GitHub::Markup.render('Foo.rst', content).encoding.name
59+
end
5360
end

0 commit comments

Comments
 (0)
Please sign in to comment.