utf8 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
- *(out+i) = *(str+i);
359
+ memcpy(out+i, str+i, curCharLen);
359
360
  }
360
361
  }
361
362
 
data/lib/utf8/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class String
2
2
  class UTF8 < ::String
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
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-21 00:00:00 -07:00
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.3.10
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