utf8 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/utf8/string_utf8.c +3 -2
- data/lib/utf8/version.rb +1 -1
- data/spec/string_spec.rb +4 -0
- metadata +5 -5
data/ext/utf8/string_utf8.c
CHANGED
@@ -350,12 +350,13 @@ static VALUE rb_cString_UTF8_clean(VALUE self) {
|
|
350
350
|
replace = REPLACEMENT_CHAR;
|
351
351
|
out = xmalloc(len);
|
352
352
|
|
353
|
-
for(i=0; i<len; i
|
353
|
+
for(i=0; i<len; i+=curCharLen) {
|
354
354
|
curCharLen = utf8CharLen(str+i, len);
|
355
355
|
if (curCharLen < 0) {
|
356
356
|
*(out+i) = replace;
|
357
|
+
curCharLen = 1;
|
357
358
|
} else {
|
358
|
-
|
359
|
+
memcpy(out+i, str+i, curCharLen);
|
359
360
|
}
|
360
361
|
}
|
361
362
|
|
data/lib/utf8/version.rb
CHANGED
data/spec/string_spec.rb
CHANGED
@@ -56,6 +56,10 @@ describe String::UTF8 do
|
|
56
56
|
orig.as_utf8.clean.should eql(clean)
|
57
57
|
end
|
58
58
|
|
59
|
+
it "clean should not replace valid utf8 chars with '?'" do
|
60
|
+
'→'.as_utf8.clean.should eql('→')
|
61
|
+
end
|
62
|
+
|
59
63
|
context "#length and #size" do
|
60
64
|
it "should be utf8-aware" do
|
61
65
|
@utf8.length.should eql(@utf8_len)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utf8
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Lopez
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements: []
|
130
130
|
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.
|
132
|
+
rubygems_version: 1.6.2
|
133
133
|
signing_key:
|
134
134
|
specification_version: 3
|
135
135
|
summary: A lightweight UTF8-aware String class meant for use with Ruby 1.8
|