Clipboard GetData with UTF-8 EURO Sign produces wrong output



Hi,

I am currently trying to read the contents of the Clipboard from
a WinForms application. I am specifically interested in the "HTML
Format" format which gets stored into the clipboard when I copy
a fragment of text containing the EURO character (Unicode 20AC)
in Word.

When calling DataObject.GetData ("HTML Format") I get a string as
result. The string does not, however, properly represent the data
stored in the clipboard.

The raw data (as seen with ClipSpy for instance) contains the
following UTF-8 byte stream :

.... E2 82 AC ...

This should decode to 20AC, since :

E2 = 1110'0010 -- 1110'zzzz
82 = 1000'0010 -- 10yy'yyyy
AC = 1010'1100 -- 10xx'xxxx

This is a 3-byte encoding sequence mapping to zzzz'yyyy'yyxx'xxxx,
which is 0010'0000'1010'1100 = 20AC = EURO Currency Symbol.

But the string returned by GetData is faulty at that point. It
contains the following, incorrectly decoded, characters :

0x00e2 0x201a

There seems to be a bug in the .NET Clipboard code implementation.

You can make my application (available at www.creativedocs.net)
crash if you copy a EURO symbol (with my keyboard layout, AltGr-E)
in Word and paste it to any text line in the application.

I'd be glad to have a work-around for this issue !

Pierre


.



Relevant Pages

  • Re: problems pasting Adobe Illustrator graphics-->Inserting them, DISCOVERY
    ... the "Clipboard" is not involved in Insert>File... ... it seems to be no longer a vector format. ... it checks the timestamp on the picture file it finds ... But if the document content and sketches are co-evolving a lot --a very ...
    (microsoft.public.mac.office.word)
  • Re: Tk::Clipboard and other kinds of data
    ... data interpreted instead of literally inserted as a raw string into the ... The manual for X clipboard is here: ... when copying RTF from within Word by using Win32::Clipboard. ... the format 49370 had the expected RTF ...
    (comp.lang.perl.tk)
  • Re: OpenClipboard
    ... YOU ARE DECLARING LOCAL VARIABLES AND NAMING THEM AS IF THEY ... OpenClipboar, an assertion failure window is pop out, and the program ... buffer to the clipboard, but it doesn't mention what format it is in; ... why you are assuming that it is in CF_BITMAP format. ...
    (microsoft.public.vc.mfc)
  • Re: Cant paste images from Snapz Pro into Word 2008
    ... But I am trying to find out what is ON THE CLIPBOARD? ... The native format an application places on the clipboard when you copy will ... with the screen capture application Snapz Pro, ...
    (microsoft.public.mac.office.word)
  • Re: Disabled CommandBarButton image in Office 2000 is always empty
    ... When I create the DIBs I face the problem that Office 2000 apps show empty command bar buttons. ... // S_OFF2000_CLIP_IMAGE was filled earlier with the localized name of the clipboard format "Toolbar Button Face" ... // I tried adding only the Toolbar format or both - neither way the disabled button image was displayed ...
    (microsoft.public.office.developer.com.add_ins)

Loading