Bug 692259 - Add unicode/utf8 copy/paste menu options to gswin32.exe
Summary: Add unicode/utf8 copy/paste menu options to gswin32.exe
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: master
Hardware: PC Windows XP
: P4 enhancement
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 12:16 UTC by Robin Watts
Modified: 2011-06-08 18:06 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Watts 2011-06-07 12:16:10 UTC
In Bug 691222 Martin Osieka suggests adding new menu options to the system menu extension on gswin32.exe to allow us to easily copy/paste unicode strings from other windows apps into gs. Spinning that out into a separate enhancement bug here to allow comments/discussion.

Since Bug 691222 has been fixed, gs is now in the position to process files with unicode characters in the filenames. This means it might be desirable to (for instance) copy a unicode filename from an explorer window and paste it into gswin32.exe's console window.

Unfortunately, this will currently fail, as gs expects all filenames internally to be utf-8 encoded.

The suggestion (as I understand it) is that we should add 2 new options on the system menu: 'Copy utf-8 as unicode' and 'Paste unicode as utf-8', that would convert the selection/clipboard contents before doing the copy/paste.
Comment 1 Martin Osieka 2011-06-07 12:55:01 UTC
(In reply to comment #0)
> In Bug 691222 Martin Osieka suggests adding new menu options to the system menu
> extension on gswin32.exe to allow us to easily copy/paste unicode strings from
> other windows apps into gs. Spinning that out into a separate enhancement bug
> here to allow comments/discussion.
> 
> Since Bug 691222 has been fixed, gs is now in the position to process files
> with unicode characters in the filenames. This means it might be desirable to
> (for instance) copy a unicode filename from an explorer window and paste it
> into gswin32.exe's console window.
> 
> Unfortunately, this will currently fail, as gs expects all filenames internally
> to be utf-8 encoded.
> 
> The suggestion (as I understand it) is that we should add 2 new options on the
> system menu: 'Copy utf-8 as unicode' and 'Paste unicode as utf-8', that would
> convert the selection/clipboard contents before doing the copy/paste.

There is no need to add two new items. Just replace in the current implementation CF_TEXT with CF_UNICODETEXT, get/put wchar_t text, and convert it from/to utf8.

This works fine because there is some magic in Windows which does char/wchar_t conversion on the clipboard. So if someone puts an ASCII text with CF_TEXT on the clipboard you will always be able to get the text with CF_UNICODETEXT.

A unicode aware application will not use CF_TEXT any longer.
Comment 2 Russell Lang 2011-06-08 12:37:40 UTC
I agree with Martin.  This also requires changing the text window (dwtext.c in gswin32.exe) to be a Unicode window, store the text buffer as Unicode, and convert it to and from UTF8 when used from dwmain.c.

I am part way through doing this conversion.
Comment 3 Robin Watts 2011-06-08 18:06:30 UTC
Fixed, in git commit 1994980.

Apologies Russell - I didn't see your comment until just now.