public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
* [PATCH] Copy and Paste with iconv
@ 2003-10-09 16:23 Kensuke Matsuzaki
  2003-10-09 18:55 ` Harold L Hunt II
  0 siblings, 1 reply; 5+ messages in thread
From: Kensuke Matsuzaki @ 2003-10-09 16:23 UTC (permalink / raw)
  To: cygwin-xfree

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

Hello,

This patch make xwinclip convert clipboard text encoding using libiconv, 
so perhaps you can copy and paste non-ASCII characters on Win9x.
But I don't have Win9X, I haven't tested it yet.

I could copy and paste Unicode text on NT/2000/XP, but CJK characters
sometimes become other CJK characters because of Han Unification.
This patch fix this problem.

For example, I use following command line option on Windows XP.
LANG=ja_JP.eucJP
XWin -clipboard -nounicodeclipboard -winencoding SHIFT_JIS -xencoding EUC-JP

Test on other language environment and 9x platform needed.

Kensuke Matsuzaki

[-- Attachment #2: clipboard_libiconv.diff --]
[-- Type: application/octet-stream, Size: 16475 bytes --]

diff -bru xwin-20031006-2120/InitOutput.c xwin/InitOutput.c
--- xwin-20031006-2120/InitOutput.c	Sat Sep 20 14:58:07 2003
+++ xwin/InitOutput.c	Thu Oct  9 17:21:47 2003
@@ -55,6 +55,11 @@
 Bool		g_fCalledSetLocale = FALSE;
 Bool		g_fCalledXInitThreads = FALSE;
 const char *	g_pszQueryHost = NULL;
+Bool		g_fUnicodeClipboard = TRUE;
+const char *	g_pszWindowsEncoding = NULL;
+const char *	g_pszXEncoding = NULL;
+iconv_t		g_icXToWin = (iconv_t)-1;
+iconv_t		g_icWinToX = (iconv_t)-1;
 
 
 /*
@@ -365,6 +370,15 @@
 
   ErrorF ("-keyboard\n"
 	  "\tSpecify a keyboard device from the configuration file.\n");
+
+  ErrorF ("-nounicodeclipboard\n"
+	  "\tDo not use Unicode even if NT-based platform.\n");
+
+  ErrorF ("-winencoding code\n"
+	  "\tSpecify Windows text encoding.\n");
+
+  ErrorF ("-xencoding code\n"
+	  "\tSpecify X text encoding.\n");
 }
 
 
@@ -1223,6 +1237,38 @@
       return 2;
     }
 
+  /*
+   * Look for the '-nounicodeclipboard' argument
+   */
+  if (IS_OPTION ("-nounicodeclipboard"))
+    {
+      g_fUnicodeClipboard = FALSE;
+      /* Indicate that we have processed the argument */
+      return 1;
+    }
+
+  /*
+   * Look for the '-winencoding' argument
+   */
+  if (IS_OPTION ("-winencoding"))
+    {
+      CHECK_ARGS (1);
+      g_pszWindowsEncoding = argv[++i];
+      /* Indicate that we have processed the argument */
+      return 2;
+    }
+
+  /*
+   * Look for the '-xencoding' argument
+   */
+  if (IS_OPTION ("-xencoding"))
+    {
+      CHECK_ARGS (1);
+      g_pszXEncoding = argv[++i];
+      /* Indicate that we have processed the argument */
+      return 2;
+    }
+
   return 0;
 }
 
@@ -1334,6 +1380,31 @@
     }
 
   LoadPreferences();
+
+  if (g_pszWindowsEncoding != NULL)
+    {
+      ErrorF ("InitOutput - iconv_open () %s to %s\n", g_pszXEncoding, g_pszWindowsEncoding);
+      g_icXToWin = iconv_open (g_pszWindowsEncoding, g_pszXEncoding);
+      if (g_icXToWin == (iconv_t)-1)
+	{
+	  ErrorF ("InitOutput - iconv_open () error\n");
+	}
+      else
+	{
+	  ErrorF ("InitOutput - iconv_open () ok\n");
+	}
+      
+      ErrorF ("InitOutput - iconv_open () %s to %s\n", g_pszWindowsEncoding, g_pszXEncoding);
+      g_icWinToX = iconv_open (g_pszXEncoding, g_pszWindowsEncoding);
+      if (g_icWinToX == (iconv_t)-1)
+	{
+	  ErrorF ("InitOutput - iconv_open () error\n");
+	}
+      else
+	{
+	  ErrorF ("InitOutput - iconv_open () ok\n");
+	}
+    }
 
 #if CYGDEBUG || YES
   ErrorF ("InitOutput - Returning.\n");
diff -bru xwin-20031006-2120/win.h xwin/win.h
--- xwin-20031006-2120/win.h	Sun Oct  5 03:48:45 2003
+++ xwin/win.h	Thu Oct  9 17:22:28 2003
@@ -132,6 +132,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <pthread.h>
+#include <iconv.h>
 
 #include <X11/XWDFile.h>
 
@@ -581,6 +582,8 @@
 extern int                      g_copyROP[];
 extern int                      g_patternROP[];
 extern const char *		g_pszQueryHost;
+extern iconv_t			g_icXToWin;
+extern iconv_t			g_icWinToX;
 
 
 /*
diff -bru xwin-20031006-2120/winclipboardthread.c xwin/winclipboardthread.c
--- xwin-20031006-2120/winclipboardthread.c	Sun Oct  5 03:49:23 2003
+++ xwin/winclipboardthread.c	Thu Oct  9 23:17:02 2003
@@ -36,6 +36,7 @@
  */
 
 extern Bool g_fCalledSetLocale;
+extern Bool g_fUnicodeClipboard;
 
 
 /*
@@ -105,10 +106,10 @@
   ErrorF ("winClipboardProc - pthread_mutex_lock () returned.\n");
 
   /* Do we have Unicode support? */
-  fUnicodeSupport = winClipboardDetectUnicodeSupport ();
+  fUnicodeSupport = g_fUnicodeClipboard && winClipboardDetectUnicodeSupport ();
 
   /* Set the current locale?  What does this do? */
-  if (fUnicodeSupport && !g_fCalledSetLocale)
+  if (!g_fCalledSetLocale)
     {
       ErrorF ("winClipboardProc - Calling setlocale ()\n");
       if (!setlocale (LC_ALL, ""))
diff -bru xwin-20031006-2120/winclipboardxevents.c xwin/winclipboardxevents.c
--- xwin-20031006-2120/winclipboardxevents.c	Tue Oct  7 10:18:22 2003
+++ xwin/winclipboardxevents.c	Fri Oct 10 00:34:43 2003
@@ -30,6 +30,15 @@
 /* $XFree86: xc/programs/Xserver/hw/xwin/winclipboardxevents.c,v 1.3 2003/10/02 13:30:10 eich Exp $ */
 
 #include "winclipboard.h"
+#include <iconv.h>
+
+
+/*
+ * References to external symbols
+ */
+
+extern iconv_t g_icXToWin;
+extern iconv_t g_icWinToX;
 
 
 /*
@@ -61,15 +70,19 @@
   HGLOBAL		hGlobal;
   Bool			fReturn = TRUE;
   XICCEncodingStyle	xiccesStyle;
-  int			iUTF8;
-  char			*pszUTF8 = NULL;
+  char			*pszConvertData = NULL;
   char			*pszTextList[2];
   int			iCount;
   char			**ppszTextList = NULL;
   wchar_t		*pwszUnicodeStr = NULL;
   int			iUnicodeLen = 0;
   int			iReturnDataLen = 0;
+  int			iGlobalDataLen = 0;
+  int			iConvertDataLen = 0;
   int			i;
+  const char		*pszIn = NULL;
+  char			*pszOut = NULL;
+  int			iInLeft, iOutLeft;
 
   /* Process all pending events */
   while (XPending (pDisplay))
@@ -253,7 +266,7 @@
 	  /* Convert the Unicode string to UTF8 (MBCS) */
 	  if (fUnicodeSupport)
 	    {
-	      iUTF8 = WideCharToMultiByte (CP_UTF8,
+	      iConvertDataLen = WideCharToMultiByte (CP_UTF8,
 					   0,
 					   (LPCWSTR)pszGlobalData,
 					   -1,
@@ -261,48 +274,85 @@
 					   0,
 					   NULL,
 					   NULL);
-	      pszUTF8 = (char *) malloc (iUTF8); /* Don't need +1 */
+	      pszConvertData = (char *) malloc (iConvertDataLen); /* Don't need +1 */
 	      WideCharToMultiByte (CP_UTF8,
 				   0,
 				   (LPCWSTR)pszGlobalData,
 				   -1,
-				   pszUTF8,
-				   iUTF8,
+				   pszConvertData,
+				   iConvertDataLen,
 				   NULL,
 				   NULL);
 	    }
+	  else
+	    {
+	      iGlobalDataLen = strlen (pszGlobalData);
+	      iConvertDataLen = iGlobalDataLen*4 + 1;
+	      pszConvertData = (char *) malloc (iConvertDataLen);
+	      if (g_icWinToX != (iconv_t)-1)
+		{
+		  pszIn = pszGlobalData;
+		  pszOut = pszConvertData;
+		  iInLeft = iGlobalDataLen;
+		  iOutLeft = iConvertDataLen;
+		  iReturn = iconv (g_icWinToX, (const char* *)&pszIn, &iInLeft, &pszOut, &iOutLeft);
+		  if (iReturn != (size_t)(-1))
+		    {
+		      iReturn = iconv (g_icWinToX, NULL, NULL, &pszOut, &iOutLeft);
+		    }
+		  pszConvertData[iConvertDataLen-iOutLeft] = '\0';
+#if 0
+		  ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+			  "iconv [%s] %d [%s] %d\n", pszGlobalData, iGlobalDataLen, pszConvertData, iConvertDataLen);
+#endif
+		}
+	      else
+		{
+		  strcpy (pszConvertData, pszGlobalData);
+#if 0
+		  ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+			  "no iconv\n");
+#endif
+		}
+	    }
 
 	  /* Convert DOS string to UNIX string */
-	  if (fUnicodeSupport)
-	    {
-	      winClipboardDOStoUNIX (pszUTF8, strlen (pszUTF8));
+	  winClipboardDOStoUNIX (pszConvertData, strlen (pszConvertData));
 
 	      /* Setup our text list */
-	      pszTextList[0] = pszUTF8;
+	  pszTextList[0] = pszConvertData;
 	      pszTextList[1] = NULL;
 	      
 	      /* Initialize the text property */
 	      xtpText.value = NULL;
 	      
 	      /* Create the text property from the text list */
+	  if (fUnicodeSupport)
+	    {
 	      iReturn = Xutf8TextListToTextProperty (pDisplay,
 						     pszTextList,
 						     1,
 						     xiccesStyle,
 						     &xtpText);
+	    }
+	  else
+	    {
+	      iReturn = XmbTextListToTextProperty (pDisplay,
+						   pszTextList,
+						   1,
+						   xiccesStyle,
+						   &xtpText);
+	    }
 	      if (iReturn == XNoMemory || iReturn == XLocaleNotSupported)
 		{
 		  ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
-			  "Xutf8TextListToTextProperty failed: %d\n",
+		      "X*TextListToTextProperty failed: %d\n",
 			  iReturn);
 		  exit(1);
 		}
 	      
-	      /* Free the UTF8 string */
-	      free (pszUTF8);
-	    }
-	  else
-	    winClipboardDOStoUNIX (pszGlobalData, strlen (pszGlobalData));
+	  /* Free the converted string */
+	  free (pszConvertData);
 
 	  /*
 	   * FIXME: Pass pszGlobalData and strlen (pszGlobalData(
@@ -311,7 +361,6 @@
 	   */
 
 	  /* Copy the clipboard text to the requesting window */
-	  if (fUnicodeSupport)
 	    iReturn = XChangeProperty (pDisplay,
 				       event.xselectionrequest.requestor,
 				       event.xselectionrequest.property,
@@ -320,15 +369,6 @@
 				       PropModeReplace,
 				       xtpText.value,
 				       xtpText.nitems);
-	  else
-	    iReturn = XChangeProperty (pDisplay,
-				       event.xselectionrequest.requestor,
-				       event.xselectionrequest.property,
-				       event.xselectionrequest.target,
-				       8,
-				       PropModeReplace,
-				       pszGlobalData,
-				       strlen (pszGlobalData));
 	  if (iReturn == BadAlloc || iReturn == BadAtom
 	      || iReturn == BadMatch || iReturn == BadValue
 	      || iReturn == BadWindow)
@@ -345,11 +385,8 @@
 	  CloseClipboard ();
 
 	  /* FIXME: Don't clean up on 1 byte. */
-	  if (fUnicodeSupport)
-	    {
 	      XFree (xtpText.value);
 	      xtpText.value = NULL;
-	    }
 
 	  /* Setup selection notify event */
 	  eventSelection.type = SelectionNotify;
@@ -410,7 +447,6 @@
 	   * What are we doing here?
 	   *
 	   */
-	  if (fUnicodeSupport)
 	    {
 	      if (event.xselection.property == None)
 		{
@@ -467,7 +503,6 @@
 	    }
 
 	  /* Retrieve the size of the stored data */
-	  if (fUnicodeSupport)
 	    iReturn = XGetWindowProperty (pDisplay,
 					  iWindow,
 					  atomLocalProperty,
@@ -480,19 +515,6 @@
 					  &xtpText.nitems,
 					  &ulReturnBytesLeft,
 					  &xtpText.value);
-	  else
-	    iReturn = XGetWindowProperty (pDisplay,
-					  iWindow,
-					  atomLocalProperty,
-					  0,
-					  0, /* Don't get data, just size */
-					  False,
-					  AnyPropertyType,
-					  &atomReturnType,
-					  &iReturnFormat,
-					  &ulReturnItems,
-					  &ulReturnBytesLeft,
-					  &pszReturnData);
 	  if (iReturn != Success)
 	    {
 	      ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
@@ -501,16 +523,11 @@
 	    }
 
 #if 0
-	  if (fUnicodeSupport)
 	    ErrorF ("SelectionNotify - returned data %d left %d\n",
 		    xtpText.nitems, ulReturnBytesLeft);
-	  else
-	    ErrorF ("SelectionNotify - returned data %d left %d\n",
-		    ulReturnItems, ulReturnBytesLeft);
 #endif
 
 	  /* Request the selection data */
-	  if (fUnicodeSupport)
 	    iReturn = XGetWindowProperty (pDisplay,
 					  iWindow,
 					  atomLocalProperty,
@@ -523,19 +540,6 @@
 					  &xtpText.nitems,
 					  &ulReturnBytesLeft,
 					  &xtpText.value);
-	  else
-	    iReturn = XGetWindowProperty (pDisplay,
-					  iWindow,
-					  atomLocalProperty,
-					  0,
-					  ulReturnBytesLeft,
-					  False,
-					  AnyPropertyType,
-					  &atomReturnType,
-					  &iReturnFormat,
-					  &ulReturnItems,
-					  &ulReturnBytesLeft,
-					  &pszReturnData);
 	  if (iReturn != Success)
 	    {
 	      ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
@@ -543,9 +547,8 @@
 	      pthread_exit (NULL);
 	    }
 
-	  if (fUnicodeSupport)
-	    {
 #if 0
+	    {
 	      char		*pszAtomName = NULL;
 
 	      ErrorF ("SelectionNotify - returned data %d left %d\n",
@@ -555,13 +558,24 @@
 	      ErrorF ("Notify atom name %s\n", pszAtomName);
 	      XFree (pszAtomName);
 	      pszAtomName = NULL;
+	    }
 #endif
 	      
+	  if (fUnicodeSupport)
+	    {
 	      /* Convert the text property to a text list */
 	      iReturn = Xutf8TextPropertyToTextList (pDisplay,
 						     &xtpText,
 						     &ppszTextList,
 						     &iCount);
+	    }
+	  else
+	    {
+	      iReturn = XmbTextPropertyToTextList (pDisplay,
+						   &xtpText,
+						   &ppszTextList,
+						   &iCount);
+	    }
 	      if (iReturn == Success || iReturn > 0)
 		{
 		  /* Conversion succeeded or some unconvertible characters */
@@ -581,7 +595,7 @@
 		  else
 		    {
 		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
-			      "Xutf8TextPropertyToTextList list_return is NULL\n");
+			      "X*TextPropertyToTextList list_return is NULL\n");
 		      pszReturnData = malloc (1);
 		      pszReturnData[0] = '\0';
 		    }
@@ -607,7 +621,6 @@
 	      /* Free the data returned from XGetWindowProperty */
 	      XFreeStringList (ppszTextList);
 	      XFree (xtpText.value);
-	    }
 	      
 	  /* Convert the X clipboard string to DOS format */
 	  winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData));
@@ -634,6 +647,37 @@
 				   pwszUnicodeStr,
 				   iUnicodeLen);
 	    }
+	  else
+	    {
+	      iReturnDataLen = strlen (pszReturnData);
+	      iConvertDataLen = iReturnDataLen*4 + 1;
+	      pszConvertData = (char *) malloc (iConvertDataLen);
+	      if (g_icXToWin != (iconv_t)-1)
+		{
+		  pszIn = pszReturnData;
+		  pszOut = pszConvertData;
+		  iInLeft = iReturnDataLen;
+		  iOutLeft = iConvertDataLen;
+		  iReturn = iconv (g_icXToWin, (const char* *)&pszIn, &iInLeft, &pszOut, &iOutLeft);
+		  if (iReturn != (size_t)(-1))
+		    {
+		      iReturn = iconv (g_icXToWin, NULL, NULL, &pszOut, &iOutLeft);
+		    }
+		  pszConvertData[iConvertDataLen-iOutLeft] = '\0';
+#if 0
+		  ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+			  "iconv [%s] %d [%s] %d\n", pszReturnData, iReturnDataLen, pszConvertData, iConvertDataLen);
+#endif
+		}
+	      else
+		{
+		  strcpy (pszConvertData, pszReturnData);
+#if 0
+		  ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+			  "no iconv\n");
+#endif
+		}
+	    }
 
 	  /* Access the Windows clipboard */
 	  if (!OpenClipboard (hwnd))
@@ -656,7 +700,7 @@
 	    hGlobal = GlobalAlloc (GMEM_MOVEABLE,
 				   sizeof (wchar_t) * (iUnicodeLen + 1));
 	  else
-	    hGlobal = GlobalAlloc (GMEM_MOVEABLE, strlen (pszReturnData) + 1);
+	    hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
 
 	  /* Obtain a pointer to the global memory */
 	  pszGlobalData = GlobalLock (hGlobal);
@@ -673,7 +717,7 @@
 		    pwszUnicodeStr,
 		    sizeof (wchar_t) * (iUnicodeLen + 1));
 	  else
-	    strcpy (pszGlobalData, pszReturnData);
+	    strcpy (pszGlobalData, pszConvertData);
 
 	  /* Free the data returned from XGetWindowProperty */
 	  if (fUnicodeSupport)
@@ -683,8 +727,8 @@
 	    }
 	  else
 	    {
-	      XFree (pszReturnData);
-	      pszReturnData = NULL;
+	      free (pszConvertData);
+	      pszConvertData = NULL;
 	    }
 
 	  /* Release the pointer to the global memory */
diff -bru xwin-20031006-2120/winmultiwindowwm.c xwin/winmultiwindowwm.c
--- xwin-20031006-2120/winmultiwindowwm.c	Sun Oct  5 03:52:22 2003
+++ xwin/winmultiwindowwm.c	Fri Oct 10 00:18:58 2003
@@ -37,6 +37,7 @@
 #include <fcntl.h>
 #include <setjmp.h>
 #include <pthread.h>
+#include <iconv.h>
 #include <X11/X.h>
 #include <X11/Xatom.h>
 #include <X11/Xlib.h>
@@ -111,6 +112,8 @@
 extern void ErrorF (const char* /*f*/, ...);
 extern Bool g_fCalledSetLocale;
 extern Bool g_fCalledXInitThreads;
+extern iconv_t g_icXToWin;
+extern iconv_t g_icWinToX;
 
 
 /*
@@ -360,6 +363,9 @@
   int			nResult, nNum;
   char			**ppList;
   XTextProperty		xtpName;
+  const char		*pszIn = NULL;
+  char			*pszOut = NULL;
+  int			iInLeft, iOutLeft;
   
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("GetWindowName\n");
@@ -399,10 +405,26 @@
       /* */
       if (nNum && ppList && *ppList)
 	{
-	  XFree (xtpName.value);
+	  if (g_icXToWin != (iconv_t)-1)
+	    {
+	      pszIn = *ppList;
+	      iInLeft = strlen(pszIn);
+	      iOutLeft = strlen(pszIn)*4 + 1;
+	      pszOut = *ppName = malloc(iOutLeft);
+	      nResult = iconv (g_icXToWin, (const char* *)&pszIn, &iInLeft, &pszOut, &iOutLeft);
+	      if (nResult != (size_t)(-1))
+		{
+		  nResult = iconv (g_icXToWin, NULL, NULL, &pszOut, &iOutLeft);
+		}
+	      (*ppList)[strlen(pszIn)*4 + 1 - iOutLeft] = '\0';
+	    }
+	  else
+	    {
 	  *ppName = strdup (*ppList);
+	    }
 	  XFreeStringList (ppList);
 	}
+      XFree (xtpName.value);
 
 #if CYGMULTIWINDOW_DEBUG
       ErrorF ("GetWindowName - %s %s\n",
@@ -974,16 +996,12 @@
  * winInitMultiWindowWM - 
  */
 
-Bool
-winClipboardDetectUnicodeSupport ();
-
 static void
 winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
 {
   int                   iRetries = 0;
   char			pszDisplay[512];
   int			iReturn;
-  Bool			fUnicodeSupport;
 
   ErrorF ("winInitMultiWindowWM - Hello\n");
 
@@ -1007,11 +1025,8 @@
 
   ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
 
-  /* Do we have Unicode support? */
-  fUnicodeSupport = winClipboardDetectUnicodeSupport ();
-
   /* Set the current locale?  What does this do? */
-  if (fUnicodeSupport && !g_fCalledSetLocale)
+  if (!g_fCalledSetLocale)
     {
       ErrorF ("winInitMultiWindowWM - Calling setlocale ()\n");
       if (!setlocale (LC_ALL, ""))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Copy and Paste with iconv
  2003-10-09 16:23 [PATCH] Copy and Paste with iconv Kensuke Matsuzaki
@ 2003-10-09 18:55 ` Harold L Hunt II
  2003-10-09 20:26   ` Benjamin Riefenstahl
  2003-10-10  4:01   ` [PATCH] " Kensuke Matsuzaki
  0 siblings, 2 replies; 5+ messages in thread
From: Harold L Hunt II @ 2003-10-09 18:55 UTC (permalink / raw)
  To: cygwin-xfree

Kensuke,

The default behavior is not affected if the new command-line parameters 
are not passed, right?  Is there anyway that you can figure out the 
-winencoding parameter from Windows?  I realize that this is an initial 
version, but it would be wise not to introduce a new command-line 
parameter only to get rid of it shortly.

Is it a good idea to add a dependency on libiconv?  I can't think of any 
reason why this would be a problem.

Harold

Kensuke Matsuzaki wrote:

> Hello,
> 
> This patch make xwinclip convert clipboard text encoding using libiconv, 
> so perhaps you can copy and paste non-ASCII characters on Win9x.
> But I don't have Win9X, I haven't tested it yet.
> 
> I could copy and paste Unicode text on NT/2000/XP, but CJK characters
> sometimes become other CJK characters because of Han Unification.
> This patch fix this problem.
> 
> For example, I use following command line option on Windows XP.
> LANG=ja_JP.eucJP
> XWin -clipboard -nounicodeclipboard -winencoding SHIFT_JIS -xencoding EUC-JP
> 
> Test on other language environment and 9x platform needed.
> 
> Kensuke Matsuzaki


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Copy and Paste with iconv
  2003-10-09 18:55 ` Harold L Hunt II
@ 2003-10-09 20:26   ` Benjamin Riefenstahl
  2003-10-10  4:01   ` [PATCH] " Kensuke Matsuzaki
  1 sibling, 0 replies; 5+ messages in thread
From: Benjamin Riefenstahl @ 2003-10-09 20:26 UTC (permalink / raw)
  To: cygwin-xfree

Hi,


Harold L Hunt II <huntharo@msu.edu> writes:
> Is there anyway that you can figure out the -winencoding parameter
> from Windows?

  char label[20];
  sprintf( label, "CP%d", (int) GetACP() );

Or something similar, you get the idea.  E.g. for SHIFT_JIS you should
get CP932, which is in the iconv list of supported encodings here.

On NT/W2K/XP, you may also want to translate to Unicode and set the
clipboard with that, too.


benny


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Copy and Paste with iconv
  2003-10-09 18:55 ` Harold L Hunt II
  2003-10-09 20:26   ` Benjamin Riefenstahl
@ 2003-10-10  4:01   ` Kensuke Matsuzaki
  2003-10-10 20:46     ` Harold L Hunt II
  1 sibling, 1 reply; 5+ messages in thread
From: Kensuke Matsuzaki @ 2003-10-10  4:01 UTC (permalink / raw)
  To: cygwin-xfree

Harold,

> The default behavior is not affected if the new command-line parameters 
> are not passed, right?

The default behavior is not affected (except bug).


> Is there anyway that you can figure out the -winencoding parameter from
> Windows?

Benjamin's way work well.
-xencoding and encoding that is specified by locale must be same.
So if there were way to get encoding from locale date,it is better.
It seems that nl_langinfo dosen't work. Any other ideas?

Hmm. I will dig deep into this.

Kensuke Matsuzaki


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Copy and Paste with iconv
  2003-10-10  4:01   ` [PATCH] " Kensuke Matsuzaki
@ 2003-10-10 20:46     ` Harold L Hunt II
  0 siblings, 0 replies; 5+ messages in thread
From: Harold L Hunt II @ 2003-10-10 20:46 UTC (permalink / raw)
  To: cygwin-xfree

Kensuke,

Kensuke Matsuzaki wrote:
> Harold,
> 
> 
>>The default behavior is not affected if the new command-line parameters 
>>are not passed, right?
> 
> 
> The default behavior is not affected (except bug).

Good.

>>Is there anyway that you can figure out the -winencoding parameter from
>>Windows?
> 
> 
> Benjamin's way work well.
> -xencoding and encoding that is specified by locale must be same.
> So if there were way to get encoding from locale date,it is better.
> It seems that nl_langinfo dosen't work. Any other ideas?
> 
> Hmm. I will dig deep into this.

Okay.  I will wait until you either send in a patch that does this 
automatically or you declare that it should be done manually for the 
time being.  I am giving preference to doing this automatically from the 
start, but I will understand if you want to just release it at some 
point to find out how it works.

Thanks for contributing,

Harold


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-10-10 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-09 16:23 [PATCH] Copy and Paste with iconv Kensuke Matsuzaki
2003-10-09 18:55 ` Harold L Hunt II
2003-10-09 20:26   ` Benjamin Riefenstahl
2003-10-10  4:01   ` [PATCH] " Kensuke Matsuzaki
2003-10-10 20:46     ` Harold L Hunt II

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).