[QScintilla] Problem with mime-data encoding

Phil Thompson phil at riverbankcomputing.com
Tue Jun 19 21:34:37 BST 2012


On Wed, 13 Jun 2012 17:31:25 +0100, Baz Walter <bazwal at ftml.net> wrote:
> Before version 2.5, qscintilla always used the unicode-friendly text 
> methods when dealing with mime-data. But this was changed when support 
> for pasting rectangular selections was added, and so there is now a real

> risk of data corruption when using the clipboard, or drag and drop.
> 
> If, for example, qscintilla is using its default code page, a copy 
> operation will store latin1 encoded data on the clipboard with a 
> mime-type of 'text/plain'. If this data is then pasted by another qt 
> widget which *does* use the text methods (such as a line-edit), all the 
> non-asciii characters will be lost (i.e. replaced by replacement 
> characters). This is because QMimeData always uses the utf-8 codec when 
> converting bytes to a QString, which of course will choke on latin1 
> encoded data.
> 
> Even worse, if two qscintilla editors using different code pages 
> exchange data, they will end up with mixed encodings. Unlike Qt, 
> Scintilla does nothing to mitigate against this and so the editors will 
> be left in an unstable state.
> 
> So I was hoping to simply suggest reverting to the unicode-friendly 
> mime-data methods to avoid such problems.

Can you try tonight's snapshot to see if I have fixed it?

> However, the latest snapshot (2.6.2-75020a35b5eb) may have introduced 
> some extra complications.
> 
> It seems that, on OSX and X11, rectangular selections now no longer have

> a mime-type of "text/plain", and instead just get the rectangular-marker

> mime-type. This is in conflict with the unicode-friendly text methods, 
> which would always enforce a mime-type of "text/plain".
> 
> The current use of the rectangular-marker mime-type is very puzzling, 
> since it means rectangular selections can now no longer be copied and 
> pasted to other widgets/applications (which won't recognize them as
text).
> 
> Is there a specific reason why this restriction has been imposed?

Yes - but not a good one.

> Rectangular selections are just ordinary lines of text - no special 
> handling is required to paste them as a stream, rather than as a block. 
> Personally, I tend to copy and paste them to other applications at least

> as much as pasting them as blocks within qscintilla - so, for me, the 
> change of behaviour is very unwelcome.

Hopefully back the way it was now.

Can you let me know if you are happy with the current behaviour - I want
to do a new release asap.

Thanks,
Phil


More information about the QScintilla mailing list