Windows gVim cannot read Chinese from clipboard created in Cygwin vim

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Windows gVim cannot read Chinese from clipboard created in Cygwin vim

Sean-130
On Windows, I have one single vimrc for both gVim and cygwin vim.
It works great, and both can input Chinese using VimIM plugin without
touching |+multi_byte_ime|.

The key vimrc setting to display Chinese are:

    set enc=utf8    gfn=Courier_New:h12:w7 fencs=ucs-bom,utf8,chinese
    set
gfw=NSimSun-18030,GulimChe,GungsuhChe,FangSong,MS_Mincho,SimHei

Now, open console vim, I can type Chinese at will:  (correct Chinese
below)

    沧海月明珠有泪
    蓝田日暖玉生烟

The problem came in when I wanted to put the content to Windows system
clipboard.

Because console vim does not support @+ or @" register, I have to
use external programs.  But that is not an issue as making system()
calls from console vim is a pleasant (sorry for gVim.exe).

Option #1, using cygwin putclip:
------------------------------
:%y|call system('putclip', @@)
------------------------------

option #2, using clip from Windows
---------------------------
:%y|call system('clip', @@)
---------------------------

Both above options worked in the way that the content (14 Chinese
characters) was put successfully in Windows clipboard.

However, when I opened gVim, and pasted from clipbard (:put *),
I found garbled characters:

From option #1, I got the following mess:
-------------------------------------
æ²§æµ·æœˆæ˜Žç  æœ‰æ³ª
è“ ç”°æ—¥æš–çŽ‰ç”ŸçƒŸ
-------------------------------------

From option #2, I got the following mess:
-------------------------------------
沧海月明珠有泪
蓝田日暖玉生烟
-------------------------------------

Further investigation shows that the content in the Windows clipboard
is not lost.
I could get the original Chinese by the following steps using gVim:

(1) gVim vimrc
set enc=ansi gfn=Courier_New:h12:w7 fencs=ansi
(2) gVim
(3) :put *
(4) :wq myfile
(5) gVim vimrc
set enc=utf8 gfn=Courier_New:h12:w7 fencs=ucs-bom,utf8,chinese
(6) gVim
(7) :r myfile

I also searched wikia, but found nothing dealing with multi-bytes:
http://vim.wikia.com/wiki/Using_the_Windows_clipboard_in_Cygwin_Vim

It looks like the issue is ++enc=utf8 cannot "translate"/"detect"
clipboard content?

Any thing do I missed?


Thanks

Sean

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Windows gVim cannot read Chinese from clipboard created in Cygwin vim

Sean-130
我把我的帖子翻译成英文,并上交国际组织:
http://groups.google.com/group/vim_use/browse_thread/thread/c01224df490d7495

让我们看看国际民间艺人的武林功夫如何。

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Windows gVim cannot read Chinese from clipboard created in Cygwin vim

bill lam
In reply to this post by Sean-130
sab, 30 Jan 2010, Sean skribis:
> Option #1, using cygwin putclip:
> ------------------------------
> :%y|call system('putclip', @@)
> ------------------------------
>
> option #2, using clip from Windows
> ---------------------------
> :%y|call system('clip', @@)
> ---------------------------

Window system clipboard use utf16 encoding.  Did you test these two
program 'putclip' and 'clip' if they accept utf8?  Or Did it work if
pasting to notepad?

--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Windows gVim cannot read Chinese from clipboard created in Cygwin vim

Sean-130
>> Or Did it work if pasting to notepad?

No. Pasting to notepad is even worse, as it all ended up with one
long line with the same garbled multi-bytes.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Windows gVim cannot read Chinese from clipboard created in Cygwin vim

bill lam
sab, 30 Jan 2010, Sean skribis:
> >> Or Did it work if pasting to notepad?
>
> No. Pasting to notepad is even worse, as it all ended up with one
> long line with the same garbled multi-bytes.

I suggest you to make sure those clip program support unicode first
and translate encoding if necessary before feeding them data.

--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Windows gVim cannot read Chinese from clipboard created in Cygwin vim

Sean-130
Further investigation shows

(1) from console vim, we can send kind of "binary" version of content
to clipboard by:
:%y|call system('/bin/putclip', @@)

(2) from gVim, we can "correct" the clipboard contents by:
:let @+=system('/bin/getclip')
(But we suffer a flash DOS box on the status line.)

(3) However, to "communicate" between console vim and gVim on the same
Windows box, it is easy to do write/read a temp file. CJK is never
garbled through "write/read" text file.

(4) It seems not possible to send readable CJK to Windows Clipboard
from console vim.

(5) Searching "clipboard" on this group showed many relating
discussions. One interesting one is the #13 "Console cygwin Vim
using win32 clipboard" on http://groups.google.com/group/vim_dev/web/vim-patches
It looks like that patch can make @+ register available for console
vim. If that is the case, the patch should be included to the official
distribution.


Thanks

Sean

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php