We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc73388 commit fdc534bCopy full SHA for fdc534b
1 file changed
core/string/shared/length.rb
@@ -36,4 +36,20 @@
36
concat.force_encoding(Encoding::ASCII_8BIT)
37
concat.size.should == 4
38
end
39
+
40
+ it "adds 1 for every invalid byte in UTF-8" do
41
+ "\xF4\x90\x80\x80".size.should == 4
42
+ "a\xF4\x90\x80\x80b".size.should == 6
43
+ "é\xF4\x90\x80\x80è".size.should == 6
44
+ end
45
46
+ it "adds 1 (and not 2) for a incomplete surrogate in UTF-16" do
47
+ "\x00\xd8".force_encoding("UTF-16LE").size.should == 1
48
+ "\xd8\x00".force_encoding("UTF-16BE").size.should == 1
49
50
51
+ it "adds 1 for a broken sequence in UTF-32" do
52
+ "\x04\x03\x02\x01".force_encoding("UTF-32LE").size.should == 1
53
+ "\x01\x02\x03\x04".force_encoding("UTF-32BE").size.should == 1
54
55
0 commit comments