delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/03/04/16:39:58

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 4 Mar 2013 22:39:02 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Drag a file into emacs-w32 frame
Message-ID: <20130304213902.GH4078@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <5134CACE DOT 9060900 AT gmail DOT com> <51351188 DOT 9010208 AT cornell DOT edu>
MIME-Version: 1.0
In-Reply-To: <51351188.9010208@cornell.edu>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Mar  4 16:26, Ken Brown wrote:
> On 3/4/2013 11:24 AM, Arthur Tu wrote:
> >Today when i tried to drag a file whose name containing chinese
> >characters into emacs, it failed to open.
> >
> >Here is the brief review:
> >
> >1. a file with a pure english file name to emacs-32 frame:
> >
> >     open successfully.
> >
> >
> >2. a file with chinese characters in its name to emacs-32 frame:
> >
> >      error message: "dnd-open-local-file: Can not read
> >file:/cygdrive/c/Users/Arthur/Desktop/%20%20%20%20.txt".
> >     in fact, i tried several times with different name. the name was
> >always decoded as a punch of "20%", even though different chinese
> >characters were there.
> >
> >
> >3. the same file with chinese characters in its name to a emacs-nox
> >frame(mintty):
> >
> >     the file name was pasted into the buffer correctly. chinese
> >characters were shown correctly. the file wasn't open. (This is what's
> >expected to happen in terminal session.)
> >
> >
> >So my question was around the situation 2.
> >How did the emacs-w32 handle the dragged file?
> 
> The code for handling the file name appears to be in src/w32fns.c.
> I don't know what the issues are in trying to make it work when the
> name contains Chinese characters.  Daniel?

Cygwin is using UTF-8 as codeset by default.  Is it possible that
w32fns.c is using *shudder* Windows functions to load the file?  If so,
it uses the current Windows ANSI codepage, perhaps cp850 or some such.

Bottom line: Use Windows functions for the GUI as much as you like.
But don't use the Windows file API.  Use Cygwin functions for that.  If
you have to use a Windows functions to fetch the filename, use the
UNICODE Windows functions (the one with the trailing W) and convert the
filename to the current Cygwin codeset using cygwin_conv_path
(CCP_WIN_W_TO_POSIX, ...).


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019