[Win32utils-devel] Fwd: [win32-clipboard] ArgumentError: invalid byte sequence in US-ASCII when copying from clipboard (#1)

Heesob Park phasis at gmail.com
Fri Jul 15 21:07:04 EDT 2011


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>


More information about the win32utils-devel mailing list