clipboard 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ == 1.0.5
2
+ * Windows 1.9 multibyte support
3
+
1
4
  == 1.0.4
2
5
  * Restore 1.8 Support
3
6
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clipboard (1.0.4)
4
+ clipboard (1.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -43,4 +43,6 @@ Copyright (c) 2010-2013 Jan Lelis <http://happycode.org> released under the MIT
43
43
  Contributions by and thanks to
44
44
  * Michael Grosser
45
45
 
46
+ See https://github.com/janlelis/clipboard/graphs/contributors for full list!
47
+
46
48
  J-_-L
@@ -1,3 +1,3 @@
1
1
  module Clipboard
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -35,6 +35,7 @@ module Clipboard::Windows
35
35
 
36
36
  attach_function :lock, :GlobalLock, [ :long ], :pointer
37
37
  attach_function :unlock, :GlobalUnlock, [ :long ], :long
38
+ attach_function :size, :GlobalSize, [ :long ], :long
38
39
  attach_function :alloc, :GlobalAlloc, [ :long, :long ], :long
39
40
  end
40
41
 
@@ -47,16 +48,13 @@ module Clipboard::Windows
47
48
  pointer_to_data = Kernel32.lock( hclip )
48
49
  data = ""
49
50
  # Windows Unicode is ended by to null bytes, so get the whole string
50
- current_byte = 0
51
- until data.size >= 2 && data[-1].ord == 0 && data[-2].ord == 0
52
- data << pointer_to_data.get_bytes( current_byte, 1 )
53
- current_byte += 1
54
- end
51
+ size = Kernel32.size( hclip )
52
+ data << pointer_to_data.get_bytes( 0, size - 2 )
55
53
  if RUBY_VERSION >= '1.9'
56
- ret = data.chop.force_encoding("UTF-16LE").encode(Encoding.default_external) # TODO catch bad encodings
54
+ ret = data.force_encoding("UTF-16LE").encode(Encoding.default_external) # TODO catch bad encodings
57
55
  else # 1.8: fallback to simple CP850 encoding
58
56
  require 'iconv'
59
- utf8 = Iconv.iconv( "UTF-8", "UTF-16LE", data.chop)[0]
57
+ utf8 = Iconv.iconv( "UTF-8", "UTF-16LE", data)[0]
60
58
  ret = Iconv.iconv( "CP850", "UTF-8", utf8)[0]
61
59
  end
62
60
  if data && 0 != data
@@ -80,7 +78,7 @@ module Clipboard::Windows
80
78
  if ( RUBY_VERSION >= '1.9' ) && 0 != User32.open( 0 )
81
79
  User32.empty( )
82
80
  data = data_to_copy.encode("UTF-16LE") # TODO catch bad encodings
83
- data << 0 << 0
81
+ data << 0
84
82
  handler = Kernel32.alloc( GMEM_MOVEABLE, data.bytesize )
85
83
  pointer_to_data = Kernel32.lock( handler )
86
84
  pointer_to_data.put_bytes( 0, data, 0, data.bytesize )
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # Please note: cannot test, if it really accesses your platform clipboard.
2
3
 
3
4
  require File.expand_path('spec/spec_helper')
@@ -18,6 +19,14 @@ describe Clipboard do
18
19
  Clipboard.paste.should == "FOO\nBAR"
19
20
  end
20
21
 
22
+ if RUBY_VERSION >= "1.9"
23
+ it "can copy & paste with multibyte char" do
24
+ Encoding.default_external = "utf-8"
25
+ Clipboard.copy("日本語")
26
+ Clipboard.paste.should == "日本語"
27
+ end
28
+ end
29
+
21
30
  it "returns data on copy" do
22
31
  Clipboard.copy('xxx').should == 'xxx'
23
32
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clipboard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jan Lelis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-23 00:00:00 Z
18
+ date: 2013-04-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement