Skip to content

Commit 85a9380

Browse files
committed
Merge pull request #11 from jarthod/master
UTF-8 encoding bugfix
2 parents 6d28189 + 4ed29f6 commit 85a9380

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/bencode/core_ext/string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class String
99
# "".bencode #=> "0:"
1010
#
1111
def bencode
12-
"#{length}:#{self}"
12+
"#{bytesize}:#{self}"
1313
end
1414

1515
#

test/encoding_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# encoding: utf-8
12
require 'environment'
23

34
class EncodingTest < MiniTest::Unit::TestCase
45
context "The BEncode encoder" do
56
should_encode "i42e", 42
67
should_encode "3:foo", "foo"
8+
should_encode "5:café", "café"
79
end
810
end

0 commit comments

Comments
 (0)