Daniel Berger
2011-Jul-14 15:13 UTC
[Win32utils-devel] Fwd: [win32-clipboard] ArgumentError: invalid byte sequence in US-ASCII when copying from clipboard (#1)
Bug posted by Max Mitchell on github for win32-clipboard. Suggestions? --- If I have the following copied into my Windows clipboard: `Hello world, ?12 is the cost` and I try to access the clipboard: ```ruby require ''rubygems'' require ''win32/clipboard'' include Win32 c = Clipboard.data ``` ... I get an `ArgumentError: invalid byte sequence in US-ASCII` from line 123 in `clipboard.rb` caused by using the pound symbol. If I try force the clipboard to read as Unicode it gives the same error. Is there a way to read in these characters/the full clipboard? I''m using the following: * Windows XP * Ruby 1.9.2p180 (2011-02-18) * win32/clipboard 0.5.2
Heesob Park
2011-Jul-16 01:07 UTC
[Win32utils-devel] Fwd: [win32-clipboard] ArgumentError: invalid byte sequence in US-ASCII when copying from clipboard (#1)
Hi, 2011/7/15 Daniel Berger <djberg96 at gmail.com>> Bug posted by Max Mitchell on github for win32-clipboard. Suggestions? > > --- > If I have the following copied into my Windows clipboard: `Hello world, ?12 > is the cost` and I try to access the clipboard: > > ```ruby > require ''rubygems'' > require ''win32/clipboard'' > include Win32 > > c = Clipboard.data > ``` > ... I get an `ArgumentError: invalid byte sequence in US-ASCII` from line > 123 in `clipboard.rb` caused by using the pound symbol. If I try force the > clipboard to read as Unicode it gives the same error. Is there a way to read > in these characters/the full clipboard? > > I''m using the following: > > * Windows XP > * Ruby 1.9.2p180 (2011-02-18) > * win32/clipboard 0.5.2 > >I think the line # 123 of clipboard.rb clip_data = clip_data[ /^[^\0]*/ ] should be replaced with clip_data = clip_data.chomp("\x00") Regards, Park Heesob -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/win32utils-devel/attachments/20110716/d22c0413/attachment.html>
Daniel Berger
2011-Jul-18 06:48 UTC
[Win32utils-devel] Fwd: [win32-clipboard] ArgumentError: invalid byte sequence in US-ASCII when copying from clipboard (#1)
On Fri, Jul 15, 2011 at 8:07 PM, Heesob Park <phasis at gmail.com> wrote:> Hi, > > 2011/7/15 Daniel Berger <djberg96 at gmail.com> >> >> Bug posted by Max Mitchell on github for win32-clipboard. Suggestions? >> >> --- >> If I have the following copied into my Windows clipboard: `Hello world, >> ?12 is the cost` and I try to access the clipboard: >> >> ```ruby >> require ''rubygems'' >> require ''win32/clipboard'' >> include Win32 >> >> c = Clipboard.data >> ``` >> ... I get an `ArgumentError: invalid byte sequence in US-ASCII` from line >> 123 in `clipboard.rb` caused by using the pound symbol. If I try force the >> clipboard to read as Unicode it gives the same error. Is there a way to read >> in these characters/the full clipboard? >> >> I''m using the following: >> >> * Windows XP >> * Ruby 1.9.2p180 (2011-02-18) >> * win32/clipboard 0.5.2 >> > > I think the line # 123 of clipboard.rb > ? ? ?clip_data = clip_data[ /^[^\0]*/ ] > should be replaced with > ? ? ?clip_data = clip_data.chomp("\x00")I tried that, but it seemed to cause other test failures. I did update the test file to explicitly set the encoding to utf-8. Perhaps that was a mistake? Regards, Dan