Karsten Hopp 902bb6
To: vim-dev@vim.org
Karsten Hopp 902bb6
Subject: Patch 7.2.049 (extra)
Karsten Hopp 902bb6
Fcc: outbox
Karsten Hopp 902bb6
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 902bb6
Mime-Version: 1.0
Karsten Hopp 902bb6
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 902bb6
Content-Transfer-Encoding: 8bit
Karsten Hopp 902bb6
------------
Karsten Hopp 902bb6
Karsten Hopp 902bb6
Patch 7.2.049 (extra)
Karsten Hopp 902bb6
Problem:    Win32: the clipboard doesn't support UTF-16.
Karsten Hopp 902bb6
Solution:   Change UCS-2 support to UTF-16 support. (Jia Yanwei)
Karsten Hopp 902bb6
Files:	    src/gui_w32.c, src/gui_w48.c, src/mbyte.c, src/misc1.c,
Karsten Hopp 902bb6
	    src/os_mswin.c, src/os_win32.c, src/proto/os_mswin.pro
Karsten Hopp 902bb6
Karsten Hopp 902bb6
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/gui_w32.c	Tue Jun 24 23:46:14 2008
Karsten Hopp 902bb6
--- src/gui_w32.c	Thu Nov 20 16:47:10 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 992,998 ****
Karsten Hopp 902bb6
  			    SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
Karsten Hopp 902bb6
  								      0, 500);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 			    tt_text = enc_to_ucs2(str, NULL);
Karsten Hopp 902bb6
  			    lpdi->lpszText = tt_text;
Karsten Hopp 902bb6
  			    /* can't show tooltip if failed */
Karsten Hopp 902bb6
  			}
Karsten Hopp 902bb6
--- 992,998 ----
Karsten Hopp 902bb6
  			    SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
Karsten Hopp 902bb6
  								      0, 500);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 			    tt_text = enc_to_utf16(str, NULL);
Karsten Hopp 902bb6
  			    lpdi->lpszText = tt_text;
Karsten Hopp 902bb6
  			    /* can't show tooltip if failed */
Karsten Hopp 902bb6
  			}
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1935,1941 ****
Karsten Hopp 902bb6
      if (buf == NULL)
Karsten Hopp 902bb6
  	return NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
!     convbuf = ucs2_to_enc(buf, lenp);
Karsten Hopp 902bb6
      pImmReleaseContext(hwnd, hIMC);
Karsten Hopp 902bb6
      vim_free(buf);
Karsten Hopp 902bb6
      return convbuf;
Karsten Hopp 902bb6
--- 1935,1941 ----
Karsten Hopp 902bb6
      if (buf == NULL)
Karsten Hopp 902bb6
  	return NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
!     convbuf = utf16_to_enc(buf, lenp);
Karsten Hopp 902bb6
      pImmReleaseContext(hwnd, hIMC);
Karsten Hopp 902bb6
      vim_free(buf);
Karsten Hopp 902bb6
      return convbuf;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2566,2572 ****
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		/* 'encoding' differs from active codepage: convert menu name
Karsten Hopp 902bb6
  		 * and use wide function */
Karsten Hopp 902bb6
! 		wn = enc_to_ucs2(menu->name, NULL);
Karsten Hopp 902bb6
  		if (wn != NULL)
Karsten Hopp 902bb6
  		{
Karsten Hopp 902bb6
  		    MENUITEMINFOW	infow;
Karsten Hopp 902bb6
--- 2566,2572 ----
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		/* 'encoding' differs from active codepage: convert menu name
Karsten Hopp 902bb6
  		 * and use wide function */
Karsten Hopp 902bb6
! 		wn = enc_to_utf16(menu->name, NULL);
Karsten Hopp 902bb6
  		if (wn != NULL)
Karsten Hopp 902bb6
  		{
Karsten Hopp 902bb6
  		    MENUITEMINFOW	infow;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2728,2734 ****
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    /* 'encoding' differs from active codepage: convert menu item name
Karsten Hopp 902bb6
  	     * and use wide function */
Karsten Hopp 902bb6
! 	    wn = enc_to_ucs2(menu->name, NULL);
Karsten Hopp 902bb6
  	    if (wn != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		n = InsertMenuW(parent->submenu_id, (UINT)idx,
Karsten Hopp 902bb6
--- 2728,2734 ----
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    /* 'encoding' differs from active codepage: convert menu item name
Karsten Hopp 902bb6
  	     * and use wide function */
Karsten Hopp 902bb6
! 	    wn = enc_to_utf16(menu->name, NULL);
Karsten Hopp 902bb6
  	    if (wn != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		n = InsertMenuW(parent->submenu_id, (UINT)idx,
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3570,3576 ****
Karsten Hopp 902bb6
      if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* Not a codepage, use our own conversion function. */
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(lpAnsiIn, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    wcscpy(lpWCStr, wn);
Karsten Hopp 902bb6
--- 3570,3576 ----
Karsten Hopp 902bb6
      if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* Not a codepage, use our own conversion function. */
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(lpAnsiIn, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    wcscpy(lpWCStr, wn);
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/gui_w48.c	Wed Nov 12 13:35:31 2008
Karsten Hopp 902bb6
--- src/gui_w48.c	Thu Nov 20 16:42:32 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 547,553 ****
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    len = 1;
Karsten Hopp 902bb6
! 	    ws = ucs2_to_enc(wstring, &len;;
Karsten Hopp 902bb6
  	    if (ws == NULL)
Karsten Hopp 902bb6
  		len = 0;
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
--- 547,553 ----
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    len = 1;
Karsten Hopp 902bb6
! 	    ws = utf16_to_enc(wstring, &len;;
Karsten Hopp 902bb6
  	    if (ws == NULL)
Karsten Hopp 902bb6
  		len = 0;
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2128,2134 ****
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* 'encoding' differs from active codepage: convert text and use wide
Karsten Hopp 902bb6
  	 * function */
Karsten Hopp 902bb6
! 	wstr = enc_to_ucs2(str, &wlen);
Karsten Hopp 902bb6
  	if (wstr != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    n = GetTextExtentPointW(hdc, wstr, wlen, &size);
Karsten Hopp 902bb6
--- 2128,2134 ----
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* 'encoding' differs from active codepage: convert text and use wide
Karsten Hopp 902bb6
  	 * function */
Karsten Hopp 902bb6
! 	wstr = enc_to_utf16(str, &wlen);
Karsten Hopp 902bb6
  	if (wstr != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    n = GetTextExtentPointW(hdc, wstr, wlen, &size);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2252,2258 ****
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* 'encoding' differs from active codepage: convert menu name
Karsten Hopp 902bb6
  	 * and use wide function */
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(item_text, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    MENUITEMINFOW	infow;
Karsten Hopp 902bb6
--- 2252,2258 ----
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* 'encoding' differs from active codepage: convert menu name
Karsten Hopp 902bb6
  	 * and use wide function */
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(item_text, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    MENUITEMINFOW	infow;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2422,2428 ****
Karsten Hopp 902bb6
  	if (use_unicode)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    /* Need to go through Unicode. */
Karsten Hopp 902bb6
! 	    wstr = enc_to_ucs2(NameBuff, NULL);
Karsten Hopp 902bb6
  	    if (wstr != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		TCITEMW		tiw;
Karsten Hopp 902bb6
--- 2422,2428 ----
Karsten Hopp 902bb6
  	if (use_unicode)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    /* Need to go through Unicode. */
Karsten Hopp 902bb6
! 	    wstr = enc_to_utf16(NameBuff, NULL);
Karsten Hopp 902bb6
  	    if (wstr != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		TCITEMW		tiw;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2521,2528 ****
Karsten Hopp 902bb6
  	WCHAR	*wbuf;
Karsten Hopp 902bb6
  	int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	/* Convert the title from 'encoding' to ucs2. */
Karsten Hopp 902bb6
! 	wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
Karsten Hopp 902bb6
  	if (wbuf != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    n = SetWindowTextW(hwnd, wbuf);
Karsten Hopp 902bb6
--- 2521,2528 ----
Karsten Hopp 902bb6
  	WCHAR	*wbuf;
Karsten Hopp 902bb6
  	int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	/* Convert the title from 'encoding' to UTF-16. */
Karsten Hopp 902bb6
! 	wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
Karsten Hopp 902bb6
  	if (wbuf != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    n = SetWindowTextW(hwnd, wbuf);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3222,3228 ****
Karsten Hopp 902bb6
  	char_u *initdir,
Karsten Hopp 902bb6
  	char_u *filter)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
!     /* We always use the wide function.  This means enc_to_ucs2() must work,
Karsten Hopp 902bb6
       * otherwise it fails miserably! */
Karsten Hopp 902bb6
      OPENFILENAMEW	fileStruct;
Karsten Hopp 902bb6
      WCHAR		fileBuf[MAXPATHL];
Karsten Hopp 902bb6
--- 3222,3228 ----
Karsten Hopp 902bb6
  	char_u *initdir,
Karsten Hopp 902bb6
  	char_u *filter)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
!     /* We always use the wide function.  This means enc_to_utf16() must work,
Karsten Hopp 902bb6
       * otherwise it fails miserably! */
Karsten Hopp 902bb6
      OPENFILENAMEW	fileStruct;
Karsten Hopp 902bb6
      WCHAR		fileBuf[MAXPATHL];
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3238,3244 ****
Karsten Hopp 902bb6
  	fileBuf[0] = NUL;
Karsten Hopp 902bb6
      else
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wp = enc_to_ucs2(dflt, NULL);
Karsten Hopp 902bb6
  	if (wp == NULL)
Karsten Hopp 902bb6
  	    fileBuf[0] = NUL;
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
--- 3238,3244 ----
Karsten Hopp 902bb6
  	fileBuf[0] = NUL;
Karsten Hopp 902bb6
      else
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wp = enc_to_utf16(dflt, NULL);
Karsten Hopp 902bb6
  	if (wp == NULL)
Karsten Hopp 902bb6
  	    fileBuf[0] = NUL;
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3263,3273 ****
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (title != NULL)
Karsten Hopp 902bb6
! 	titlep = enc_to_ucs2(title, NULL);
Karsten Hopp 902bb6
      fileStruct.lpstrTitle = titlep;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (ext != NULL)
Karsten Hopp 902bb6
! 	extp = enc_to_ucs2(ext, NULL);
Karsten Hopp 902bb6
      fileStruct.lpstrDefExt = extp;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      fileStruct.lpstrFile = fileBuf;
Karsten Hopp 902bb6
--- 3263,3273 ----
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (title != NULL)
Karsten Hopp 902bb6
! 	titlep = enc_to_utf16(title, NULL);
Karsten Hopp 902bb6
      fileStruct.lpstrTitle = titlep;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (ext != NULL)
Karsten Hopp 902bb6
! 	extp = enc_to_utf16(ext, NULL);
Karsten Hopp 902bb6
      fileStruct.lpstrDefExt = extp;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      fileStruct.lpstrFile = fileBuf;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3278,3284 ****
Karsten Hopp 902bb6
      if (initdir != NULL && *initdir != NUL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* Must have backslashes here, no matter what 'shellslash' says */
Karsten Hopp 902bb6
! 	initdirp = enc_to_ucs2(initdir, NULL);
Karsten Hopp 902bb6
  	if (initdirp != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    for (wp = initdirp; *wp != NUL; ++wp)
Karsten Hopp 902bb6
--- 3278,3284 ----
Karsten Hopp 902bb6
      if (initdir != NULL && *initdir != NUL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* Must have backslashes here, no matter what 'shellslash' says */
Karsten Hopp 902bb6
! 	initdirp = enc_to_utf16(initdir, NULL);
Karsten Hopp 902bb6
  	if (initdirp != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    for (wp = initdirp; *wp != NUL; ++wp)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3318,3324 ****
Karsten Hopp 902bb6
      vim_free(extp);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      /* Convert from UCS2 to 'encoding'. */
Karsten Hopp 902bb6
!     p = ucs2_to_enc(fileBuf, NULL);
Karsten Hopp 902bb6
      if (p != NULL)
Karsten Hopp 902bb6
  	/* when out of memory we get garbage for non-ASCII chars */
Karsten Hopp 902bb6
  	STRCPY(fileBuf, p);
Karsten Hopp 902bb6
--- 3318,3324 ----
Karsten Hopp 902bb6
      vim_free(extp);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      /* Convert from UCS2 to 'encoding'. */
Karsten Hopp 902bb6
!     p = utf16_to_enc(fileBuf, NULL);
Karsten Hopp 902bb6
      if (p != NULL)
Karsten Hopp 902bb6
  	/* when out of memory we get garbage for non-ASCII chars */
Karsten Hopp 902bb6
  	STRCPY(fileBuf, p);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 3518,3524 ****
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
  	    if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
Karsten Hopp 902bb6
! 		fnames[i] = ucs2_to_enc(wszFile, NULL);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
--- 3518,3524 ----
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
  	    if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
Karsten Hopp 902bb6
! 		fnames[i] = utf16_to_enc(wszFile, NULL);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/mbyte.c	Thu Nov 20 11:55:53 2008
Karsten Hopp 902bb6
--- src/mbyte.c	Thu Nov 20 16:47:41 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 6101,6107 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    /* 1. codepage/UTF-8  ->  ucs-2. */
Karsten Hopp 902bb6
  	    if (vcp->vc_cpfrom == 0)
Karsten Hopp 902bb6
! 		tmp_len = utf8_to_ucs2(ptr, len, NULL, NULL);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  		tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
Karsten Hopp 902bb6
  							      ptr, len, 0, 0);
Karsten Hopp 902bb6
--- 6101,6107 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    /* 1. codepage/UTF-8  ->  ucs-2. */
Karsten Hopp 902bb6
  	    if (vcp->vc_cpfrom == 0)
Karsten Hopp 902bb6
! 		tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  		tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
Karsten Hopp 902bb6
  							      ptr, len, 0, 0);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 6109,6121 ****
Karsten Hopp 902bb6
  	    if (tmp == NULL)
Karsten Hopp 902bb6
  		break;
Karsten Hopp 902bb6
  	    if (vcp->vc_cpfrom == 0)
Karsten Hopp 902bb6
! 		utf8_to_ucs2(ptr, len, tmp, unconvlenp);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  		MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    /* 2. ucs-2  ->  codepage/UTF-8. */
Karsten Hopp 902bb6
  	    if (vcp->vc_cpto == 0)
Karsten Hopp 902bb6
! 		retlen = ucs2_to_utf8(tmp, tmp_len, NULL);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  		retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
Karsten Hopp 902bb6
  						    tmp, tmp_len, 0, 0, 0, 0);
Karsten Hopp 902bb6
--- 6109,6121 ----
Karsten Hopp 902bb6
  	    if (tmp == NULL)
Karsten Hopp 902bb6
  		break;
Karsten Hopp 902bb6
  	    if (vcp->vc_cpfrom == 0)
Karsten Hopp 902bb6
! 		utf8_to_utf16(ptr, len, tmp, unconvlenp);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  		MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    /* 2. ucs-2  ->  codepage/UTF-8. */
Karsten Hopp 902bb6
  	    if (vcp->vc_cpto == 0)
Karsten Hopp 902bb6
! 		retlen = utf16_to_utf8(tmp, tmp_len, NULL);
Karsten Hopp 902bb6
  	    else
Karsten Hopp 902bb6
  		retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
Karsten Hopp 902bb6
  						    tmp, tmp_len, 0, 0, 0, 0);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 6123,6129 ****
Karsten Hopp 902bb6
  	    if (retval != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		if (vcp->vc_cpto == 0)
Karsten Hopp 902bb6
! 		    ucs2_to_utf8(tmp, tmp_len, retval);
Karsten Hopp 902bb6
  		else
Karsten Hopp 902bb6
  		    WideCharToMultiByte(vcp->vc_cpto, 0,
Karsten Hopp 902bb6
  					  tmp, tmp_len, retval, retlen, 0, 0);
Karsten Hopp 902bb6
--- 6123,6129 ----
Karsten Hopp 902bb6
  	    if (retval != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		if (vcp->vc_cpto == 0)
Karsten Hopp 902bb6
! 		    utf16_to_utf8(tmp, tmp_len, retval);
Karsten Hopp 902bb6
  		else
Karsten Hopp 902bb6
  		    WideCharToMultiByte(vcp->vc_cpto, 0,
Karsten Hopp 902bb6
  					  tmp, tmp_len, retval, retlen, 0, 0);
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/misc1.c	Sun Nov  9 13:43:25 2008
Karsten Hopp 902bb6
--- src/misc1.c	Thu Nov 20 16:42:59 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 8728,8734 ****
Karsten Hopp 902bb6
  	/* The active codepage differs from 'encoding'.  Attempt using the
Karsten Hopp 902bb6
  	 * wide function.  If it fails because it is not implemented fall back
Karsten Hopp 902bb6
  	 * to the non-wide version (for Windows 98) */
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(buf, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    hFind = FindFirstFileW(wn, &wfb;;
Karsten Hopp 902bb6
--- 8728,8734 ----
Karsten Hopp 902bb6
  	/* The active codepage differs from 'encoding'.  Attempt using the
Karsten Hopp 902bb6
  	 * wide function.  If it fails because it is not implemented fall back
Karsten Hopp 902bb6
  	 * to the non-wide version (for Windows 98) */
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(buf, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    hFind = FindFirstFileW(wn, &wfb;;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 8756,8762 ****
Karsten Hopp 902bb6
  #ifdef WIN3264
Karsten Hopp 902bb6
  # ifdef FEAT_MBYTE
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
! 	    p = ucs2_to_enc(wfb.cFileName, NULL);   /* p is allocated here */
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
  # endif
Karsten Hopp 902bb6
  	    p = (char_u *)fb.cFileName;
Karsten Hopp 902bb6
--- 8756,8762 ----
Karsten Hopp 902bb6
  #ifdef WIN3264
Karsten Hopp 902bb6
  # ifdef FEAT_MBYTE
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
! 	    p = utf16_to_enc(wfb.cFileName, NULL);   /* p is allocated here */
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
  # endif
Karsten Hopp 902bb6
  	    p = (char_u *)fb.cFileName;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 8830,8836 ****
Karsten Hopp 902bb6
  	    if (wn != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		vim_free(wn);
Karsten Hopp 902bb6
! 		wn = enc_to_ucs2(buf, NULL);
Karsten Hopp 902bb6
  		if (wn != NULL)
Karsten Hopp 902bb6
  		    hFind = FindFirstFileW(wn, &wfb;;
Karsten Hopp 902bb6
  	    }
Karsten Hopp 902bb6
--- 8830,8836 ----
Karsten Hopp 902bb6
  	    if (wn != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
  		vim_free(wn);
Karsten Hopp 902bb6
! 		wn = enc_to_utf16(buf, NULL);
Karsten Hopp 902bb6
  		if (wn != NULL)
Karsten Hopp 902bb6
  		    hFind = FindFirstFileW(wn, &wfb;;
Karsten Hopp 902bb6
  	    }
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/os_mswin.c	Sat Aug  9 19:37:30 2008
Karsten Hopp 902bb6
--- src/os_mswin.c	Thu Nov 20 17:05:10 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 309,315 ****
Karsten Hopp 902bb6
  	if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    /* Convert the title from 'encoding' to the active codepage. */
Karsten Hopp 902bb6
! 	    WCHAR	*wp = enc_to_ucs2(title, NULL);
Karsten Hopp 902bb6
  	    int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    if (wp != NULL)
Karsten Hopp 902bb6
--- 309,315 ----
Karsten Hopp 902bb6
  	if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    /* Convert the title from 'encoding' to the active codepage. */
Karsten Hopp 902bb6
! 	    WCHAR	*wp = enc_to_utf16(title, NULL);
Karsten Hopp 902bb6
  	    int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    if (wp != NULL)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 406,415 ****
Karsten Hopp 902bb6
  	     * - invoke _wfullpath()
Karsten Hopp 902bb6
  	     * - convert the result from UCS2 to 'encoding'.
Karsten Hopp 902bb6
  	     */
Karsten Hopp 902bb6
! 	    wname = enc_to_ucs2(fname, NULL);
Karsten Hopp 902bb6
  	    if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
! 		cname = ucs2_to_enc((short_u *)wbuf, NULL);
Karsten Hopp 902bb6
  		if (cname != NULL)
Karsten Hopp 902bb6
  		{
Karsten Hopp 902bb6
  		    vim_strncpy(buf, cname, len - 1);
Karsten Hopp 902bb6
--- 406,415 ----
Karsten Hopp 902bb6
  	     * - invoke _wfullpath()
Karsten Hopp 902bb6
  	     * - convert the result from UCS2 to 'encoding'.
Karsten Hopp 902bb6
  	     */
Karsten Hopp 902bb6
! 	    wname = enc_to_utf16(fname, NULL);
Karsten Hopp 902bb6
  	    if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
! 		cname = utf16_to_enc((short_u *)wbuf, NULL);
Karsten Hopp 902bb6
  		if (cname != NULL)
Karsten Hopp 902bb6
  		{
Karsten Hopp 902bb6
  		    vim_strncpy(buf, cname, len - 1);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 507,513 ****
Karsten Hopp 902bb6
  # endif
Karsten Hopp 902bb6
         )
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*wp = enc_to_ucs2(buf, NULL);
Karsten Hopp 902bb6
  	int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (wp != NULL)
Karsten Hopp 902bb6
--- 507,513 ----
Karsten Hopp 902bb6
  # endif
Karsten Hopp 902bb6
         )
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*wp = enc_to_utf16(buf, NULL);
Karsten Hopp 902bb6
  	int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (wp != NULL)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 668,674 ****
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_ucs2(path, NULL);
Karsten Hopp 902bb6
  	int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (p != NULL)
Karsten Hopp 902bb6
--- 668,674 ----
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_utf16(path, NULL);
Karsten Hopp 902bb6
  	int	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (p != NULL)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 891,909 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  #if defined(FEAT_MBYTE) || defined(PROTO)
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert an UTF-8 string to UCS-2.
Karsten Hopp 902bb6
   * "instr[inlen]" is the input.  "inlen" is in bytes.
Karsten Hopp 902bb6
!  * When "outstr" is NULL only return the number of UCS-2 words produced.
Karsten Hopp 902bb6
   * Otherwise "outstr" must be a buffer of sufficient size.
Karsten Hopp 902bb6
!  * Returns the number of UCS-2 words produced.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      int
Karsten Hopp 902bb6
! utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      int		outlen = 0;
Karsten Hopp 902bb6
      char_u	*p = instr;
Karsten Hopp 902bb6
      int		todo = inlen;
Karsten Hopp 902bb6
      int		l;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      while (todo > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
--- 891,910 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  #if defined(FEAT_MBYTE) || defined(PROTO)
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert an UTF-8 string to UTF-16.
Karsten Hopp 902bb6
   * "instr[inlen]" is the input.  "inlen" is in bytes.
Karsten Hopp 902bb6
!  * When "outstr" is NULL only return the number of UTF-16 words produced.
Karsten Hopp 902bb6
   * Otherwise "outstr" must be a buffer of sufficient size.
Karsten Hopp 902bb6
!  * Returns the number of UTF-16 words produced.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      int
Karsten Hopp 902bb6
! utf8_to_utf16(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      int		outlen = 0;
Karsten Hopp 902bb6
      char_u	*p = instr;
Karsten Hopp 902bb6
      int		todo = inlen;
Karsten Hopp 902bb6
      int		l;
Karsten Hopp 902bb6
+     int		ch;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      while (todo > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 917,924 ****
Karsten Hopp 902bb6
  	    break;
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	if (outstr != NULL)
Karsten Hopp 902bb6
! 	    *outstr++ = utf_ptr2char(p);
Karsten Hopp 902bb6
  	++outlen;
Karsten Hopp 902bb6
  	p += l;
Karsten Hopp 902bb6
  	todo -= l;
Karsten Hopp 902bb6
--- 918,936 ----
Karsten Hopp 902bb6
  	    break;
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	ch = utf_ptr2char(p);
Karsten Hopp 902bb6
! 	if (ch >= 0x10000)
Karsten Hopp 902bb6
! 	{
Karsten Hopp 902bb6
! 	    /* non-BMP character, encoding with surrogate pairs */
Karsten Hopp 902bb6
! 	    ++outlen;
Karsten Hopp 902bb6
! 	    if (outstr != NULL)
Karsten Hopp 902bb6
! 	    {
Karsten Hopp 902bb6
! 		*outstr++ = (0xD800 - (0x10000 >> 10)) + (ch >> 10);
Karsten Hopp 902bb6
! 		*outstr++ = 0xDC00 | (ch & 0x3FF);
Karsten Hopp 902bb6
! 	    }
Karsten Hopp 902bb6
! 	}
Karsten Hopp 902bb6
! 	else if (outstr != NULL)
Karsten Hopp 902bb6
! 	    *outstr++ = ch;
Karsten Hopp 902bb6
  	++outlen;
Karsten Hopp 902bb6
  	p += l;
Karsten Hopp 902bb6
  	todo -= l;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 928,956 ****
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert an UCS-2 string to UTF-8.
Karsten Hopp 902bb6
!  * The input is "instr[inlen]" with "inlen" in number of ucs-2 words.
Karsten Hopp 902bb6
   * When "outstr" is NULL only return the required number of bytes.
Karsten Hopp 902bb6
   * Otherwise "outstr" must be a buffer of sufficient size.
Karsten Hopp 902bb6
   * Return the number of bytes produced.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      int
Karsten Hopp 902bb6
! ucs2_to_utf8(short_u *instr, int inlen, char_u *outstr)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      int		outlen = 0;
Karsten Hopp 902bb6
      int		todo = inlen;
Karsten Hopp 902bb6
      short_u	*p = instr;
Karsten Hopp 902bb6
      int		l;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      while (todo > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	if (outstr != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
! 	    l = utf_char2bytes(*p, outstr);
Karsten Hopp 902bb6
  	    outstr += l;
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
! 	    l = utf_char2len(*p);
Karsten Hopp 902bb6
  	++p;
Karsten Hopp 902bb6
  	outlen += l;
Karsten Hopp 902bb6
  	--todo;
Karsten Hopp 902bb6
--- 940,981 ----
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert an UTF-16 string to UTF-8.
Karsten Hopp 902bb6
!  * The input is "instr[inlen]" with "inlen" in number of UTF-16 words.
Karsten Hopp 902bb6
   * When "outstr" is NULL only return the required number of bytes.
Karsten Hopp 902bb6
   * Otherwise "outstr" must be a buffer of sufficient size.
Karsten Hopp 902bb6
   * Return the number of bytes produced.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      int
Karsten Hopp 902bb6
! utf16_to_utf8(short_u *instr, int inlen, char_u *outstr)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      int		outlen = 0;
Karsten Hopp 902bb6
      int		todo = inlen;
Karsten Hopp 902bb6
      short_u	*p = instr;
Karsten Hopp 902bb6
      int		l;
Karsten Hopp 902bb6
+     int		ch, ch2;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      while (todo > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
+ 	ch = *p;
Karsten Hopp 902bb6
+ 	if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1)
Karsten Hopp 902bb6
+ 	{
Karsten Hopp 902bb6
+ 	    /* surrogate pairs handling */
Karsten Hopp 902bb6
+ 	    ch2 = p[1];
Karsten Hopp 902bb6
+ 	    if (ch2 >= 0xDC00 && ch2 <= 0xDFFF)
Karsten Hopp 902bb6
+ 	    {
Karsten Hopp 902bb6
+ 		ch = ((ch - 0xD800) << 10) + (ch2 & 0x3FF) + 0x10000;
Karsten Hopp 902bb6
+ 		++p;
Karsten Hopp 902bb6
+ 		--todo;
Karsten Hopp 902bb6
+ 	    }
Karsten Hopp 902bb6
+ 	}
Karsten Hopp 902bb6
  	if (outstr != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
! 	    l = utf_char2bytes(ch, outstr);
Karsten Hopp 902bb6
  	    outstr += l;
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  	else
Karsten Hopp 902bb6
! 	    l = utf_char2len(ch);
Karsten Hopp 902bb6
  	++p;
Karsten Hopp 902bb6
  	outlen += l;
Karsten Hopp 902bb6
  	--todo;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1079,1092 ****
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert "str" from 'encoding' to UCS-2.
Karsten Hopp 902bb6
   * Input in "str" with length "*lenp".  When "lenp" is NULL, use strlen().
Karsten Hopp 902bb6
   * Output is returned as an allocated string.  "*lenp" is set to the length of
Karsten Hopp 902bb6
   * the result.  A trailing NUL is always added.
Karsten Hopp 902bb6
   * Returns NULL when out of memory.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      short_u *
Karsten Hopp 902bb6
! enc_to_ucs2(char_u *str, int *lenp)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      vimconv_T	conv;
Karsten Hopp 902bb6
      WCHAR	*ret;
Karsten Hopp 902bb6
--- 1104,1117 ----
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert "str" from 'encoding' to UTF-16.
Karsten Hopp 902bb6
   * Input in "str" with length "*lenp".  When "lenp" is NULL, use strlen().
Karsten Hopp 902bb6
   * Output is returned as an allocated string.  "*lenp" is set to the length of
Karsten Hopp 902bb6
   * the result.  A trailing NUL is always added.
Karsten Hopp 902bb6
   * Returns NULL when out of memory.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      short_u *
Karsten Hopp 902bb6
! enc_to_utf16(char_u *str, int *lenp)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      vimconv_T	conv;
Karsten Hopp 902bb6
      WCHAR	*ret;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1102,1108 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	/* We can do any CP### -> UCS-2 in one pass, and we can do it
Karsten Hopp 902bb6
  	 * without iconv() (convert_* may need iconv). */
Karsten Hopp 902bb6
  	MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
--- 1127,1133 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	/* We can do any CP### -> UTF-16 in one pass, and we can do it
Karsten Hopp 902bb6
  	 * without iconv() (convert_* may need iconv). */
Karsten Hopp 902bb6
  	MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1123,1133 ****
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  	convert_setup(&conv, NULL, NULL);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	length = utf8_to_ucs2(str, *lenp, NULL, NULL);
Karsten Hopp 902bb6
  	ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
Karsten Hopp 902bb6
  	if (ret != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
! 	    utf8_to_ucs2(str, *lenp, (short_u *)ret, NULL);
Karsten Hopp 902bb6
  	    ret[length] = 0;
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
--- 1148,1158 ----
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  	convert_setup(&conv, NULL, NULL);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	length = utf8_to_utf16(str, *lenp, NULL, NULL);
Karsten Hopp 902bb6
  	ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
Karsten Hopp 902bb6
  	if (ret != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
! 	    utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
Karsten Hopp 902bb6
  	    ret[length] = 0;
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1139,1145 ****
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert an UCS-2 string to 'encoding'.
Karsten Hopp 902bb6
   * Input in "str" with length (counted in wide characters) "*lenp".  When
Karsten Hopp 902bb6
   * "lenp" is NULL, use wcslen().
Karsten Hopp 902bb6
   * Output is returned as an allocated string.  If "*lenp" is not NULL it is
Karsten Hopp 902bb6
--- 1164,1170 ----
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Convert an UTF-16 string to 'encoding'.
Karsten Hopp 902bb6
   * Input in "str" with length (counted in wide characters) "*lenp".  When
Karsten Hopp 902bb6
   * "lenp" is NULL, use wcslen().
Karsten Hopp 902bb6
   * Output is returned as an allocated string.  If "*lenp" is not NULL it is
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1147,1153 ****
Karsten Hopp 902bb6
   * Returns NULL when out of memory.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      char_u *
Karsten Hopp 902bb6
! ucs2_to_enc(short_u *str, int *lenp)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      vimconv_T	conv;
Karsten Hopp 902bb6
      char_u	*utf8_str = NULL, *enc_str = NULL;
Karsten Hopp 902bb6
--- 1172,1178 ----
Karsten Hopp 902bb6
   * Returns NULL when out of memory.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      char_u *
Karsten Hopp 902bb6
! utf16_to_enc(short_u *str, int *lenp)
Karsten Hopp 902bb6
  {
Karsten Hopp 902bb6
      vimconv_T	conv;
Karsten Hopp 902bb6
      char_u	*utf8_str = NULL, *enc_str = NULL;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1161,1167 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	/* We can do any UCS-2 -> CP### in one pass. */
Karsten Hopp 902bb6
  	int length;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
Karsten Hopp 902bb6
--- 1186,1192 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage > 0)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	/* We can do any UTF-16 -> CP### in one pass. */
Karsten Hopp 902bb6
  	int length;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1171,1180 ****
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      /* Avoid allocating zero bytes, it generates an error message. */
Karsten Hopp 902bb6
!     utf8_str = alloc(ucs2_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
Karsten Hopp 902bb6
      if (utf8_str != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	*lenp = ucs2_to_utf8(str, *lenp, utf8_str);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	/* We might be called before we have p_enc set up. */
Karsten Hopp 902bb6
  	conv.vc_type = CONV_NONE;
Karsten Hopp 902bb6
--- 1196,1205 ----
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      /* Avoid allocating zero bytes, it generates an error message. */
Karsten Hopp 902bb6
!     utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
Karsten Hopp 902bb6
      if (utf8_str != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	*lenp = utf16_to_utf8(str, *lenp, utf8_str);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	/* We might be called before we have p_enc set up. */
Karsten Hopp 902bb6
  	conv.vc_type = CONV_NONE;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1308,1314 ****
Karsten Hopp 902bb6
  		    if (hMemWstr[str_size] == NUL)
Karsten Hopp 902bb6
  			break;
Karsten Hopp 902bb6
  	    }
Karsten Hopp 902bb6
! 	    to_free = str = ucs2_to_enc((short_u *)hMemWstr, &str_size);
Karsten Hopp 902bb6
  	    GlobalUnlock(hMemW);
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
--- 1333,1339 ----
Karsten Hopp 902bb6
  		    if (hMemWstr[str_size] == NUL)
Karsten Hopp 902bb6
  			break;
Karsten Hopp 902bb6
  	    }
Karsten Hopp 902bb6
! 	    to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
Karsten Hopp 902bb6
  	    GlobalUnlock(hMemW);
Karsten Hopp 902bb6
  	}
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1340,1346 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp 902bb6
  	    /* The text is in the active codepage.  Convert to 'encoding',
Karsten Hopp 902bb6
! 	     * going through UCS-2. */
Karsten Hopp 902bb6
  	    acp_to_enc(str, str_size, &to_free, &maxlen);
Karsten Hopp 902bb6
  	    if (to_free != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
--- 1365,1371 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  # if defined(FEAT_MBYTE) && defined(WIN3264)
Karsten Hopp 902bb6
  	    /* The text is in the active codepage.  Convert to 'encoding',
Karsten Hopp 902bb6
! 	     * going through UTF-16. */
Karsten Hopp 902bb6
  	    acp_to_enc(str, str_size, &to_free, &maxlen);
Karsten Hopp 902bb6
  	    if (to_free != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1404,1410 ****
Karsten Hopp 902bb6
      if (widestr != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	++*outlen;	/* Include the 0 after the string */
Karsten Hopp 902bb6
! 	*out = ucs2_to_enc((short_u *)widestr, outlen);
Karsten Hopp 902bb6
  	vim_free(widestr);
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
--- 1429,1435 ----
Karsten Hopp 902bb6
      if (widestr != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	++*outlen;	/* Include the 0 after the string */
Karsten Hopp 902bb6
! 	*out = utf16_to_enc((short_u *)widestr, outlen);
Karsten Hopp 902bb6
  	vim_free(widestr);
Karsten Hopp 902bb6
      }
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1466,1474 ****
Karsten Hopp 902bb6
  	WCHAR		*out;
Karsten Hopp 902bb6
  	int		len = metadata.txtlen;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	/* Convert the text to UCS-2. This is put on the clipboard as
Karsten Hopp 902bb6
  	 * CF_UNICODETEXT. */
Karsten Hopp 902bb6
! 	out = (WCHAR *)enc_to_ucs2(str, &len;;
Karsten Hopp 902bb6
  	if (out != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    WCHAR *lpszMemW;
Karsten Hopp 902bb6
--- 1491,1499 ----
Karsten Hopp 902bb6
  	WCHAR		*out;
Karsten Hopp 902bb6
  	int		len = metadata.txtlen;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	/* Convert the text to UTF-16. This is put on the clipboard as
Karsten Hopp 902bb6
  	 * CF_UNICODETEXT. */
Karsten Hopp 902bb6
! 	out = (WCHAR *)enc_to_utf16(str, &len;;
Karsten Hopp 902bb6
  	if (out != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    WCHAR *lpszMemW;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1488,1494 ****
Karsten Hopp 902bb6
  	    WideCharToMultiByte(GetACP(), 0, out, len,
Karsten Hopp 902bb6
  						  str, metadata.txtlen, 0, 0);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	    /* Allocate memory for the UCS-2 text, add one NUL word to
Karsten Hopp 902bb6
  	     * terminate the string. */
Karsten Hopp 902bb6
  	    hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
Karsten Hopp 902bb6
  						   (len + 1) * sizeof(WCHAR));
Karsten Hopp 902bb6
--- 1513,1519 ----
Karsten Hopp 902bb6
  	    WideCharToMultiByte(GetACP(), 0, out, len,
Karsten Hopp 902bb6
  						  str, metadata.txtlen, 0, 0);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
! 	    /* Allocate memory for the UTF-16 text, add one NUL word to
Karsten Hopp 902bb6
  	     * terminate the string. */
Karsten Hopp 902bb6
  	    hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
Karsten Hopp 902bb6
  						   (len + 1) * sizeof(WCHAR));
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/os_win32.c	Thu Jul 24 20:50:30 2008
Karsten Hopp 902bb6
--- src/os_win32.c	Thu Nov 20 16:44:33 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 1587,1593 ****
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
  	WCHAR	fnamew[_MAX_PATH];
Karsten Hopp 902bb6
  	WCHAR	*dumw;
Karsten Hopp 902bb6
  	long	n;
Karsten Hopp 902bb6
--- 1587,1593 ----
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
  	WCHAR	fnamew[_MAX_PATH];
Karsten Hopp 902bb6
  	WCHAR	*dumw;
Karsten Hopp 902bb6
  	long	n;
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2440,2446 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
! 	    char_u  *p = ucs2_to_enc(wbuf, NULL);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    if (p != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
--- 2440,2446 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
! 	    char_u  *p = utf16_to_enc(wbuf, NULL);
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	    if (p != NULL)
Karsten Hopp 902bb6
  	    {
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2466,2472 ****
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
  	long	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (p != NULL)
Karsten Hopp 902bb6
--- 2466,2472 ----
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
  	long	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (p != NULL)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2495,2501 ****
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
  	long	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (p != NULL)
Karsten Hopp 902bb6
--- 2495,2501 ----
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	WCHAR	*p = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
  	long	n;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  	if (p != NULL)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2522,2528 ****
Karsten Hopp 902bb6
      WCHAR	*p = NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
! 	p = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
--- 2522,2528 ----
Karsten Hopp 902bb6
      WCHAR	*p = NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
! 	p = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  #ifdef FEAT_MBYTE
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 2590,2596 ****
Karsten Hopp 902bb6
      WCHAR	*wn = NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(fname, NULL);
Karsten Hopp 902bb6
      if (wn != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	hFile = CreateFileW(wn,		/* file name */
Karsten Hopp 902bb6
--- 2590,2596 ----
Karsten Hopp 902bb6
      WCHAR	*wn = NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(fname, NULL);
Karsten Hopp 902bb6
      if (wn != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	hFile = CreateFileW(wn,		/* file name */
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4239,4245 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
Karsten Hopp 902bb6
--- 4239,4245 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4382,4389 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wold = enc_to_ucs2((char_u *)pszOldFile, NULL);
Karsten Hopp 902bb6
! 	wnew = enc_to_ucs2((char_u *)pszNewFile, NULL);
Karsten Hopp 902bb6
  	if (wold != NULL && wnew != NULL)
Karsten Hopp 902bb6
  	    retval = mch_wrename(wold, wnew);
Karsten Hopp 902bb6
  	vim_free(wold);
Karsten Hopp 902bb6
--- 4382,4389 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wold = enc_to_utf16((char_u *)pszOldFile, NULL);
Karsten Hopp 902bb6
! 	wnew = enc_to_utf16((char_u *)pszNewFile, NULL);
Karsten Hopp 902bb6
  	if (wold != NULL && wnew != NULL)
Karsten Hopp 902bb6
  	    retval = mch_wrename(wold, wnew);
Karsten Hopp 902bb6
  	vim_free(wold);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4492,4498 ****
Karsten Hopp 902bb6
      WCHAR	*wn = NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(n, NULL);
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (mch_isdir(n))
Karsten Hopp 902bb6
--- 4492,4498 ----
Karsten Hopp 902bb6
      WCHAR	*wn = NULL;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(n, NULL);
Karsten Hopp 902bb6
  #endif
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (mch_isdir(n))
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4618,4624 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  #if defined(FEAT_MBYTE) || defined(PROTO)
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Version of open() that may use ucs2 file name.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      int
Karsten Hopp 902bb6
  mch_open(char *name, int flags, int mode)
Karsten Hopp 902bb6
--- 4618,4624 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  #if defined(FEAT_MBYTE) || defined(PROTO)
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Version of open() that may use UTF-16 file name.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      int
Karsten Hopp 902bb6
  mch_open(char *name, int flags, int mode)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4630,4636 ****
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    f = _wopen(wn, flags, mode);
Karsten Hopp 902bb6
--- 4630,4636 ----
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  	    f = _wopen(wn, flags, mode);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4648,4654 ****
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Version of fopen() that may use ucs2 file name.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      FILE *
Karsten Hopp 902bb6
  mch_fopen(char *name, char *mode)
Karsten Hopp 902bb6
--- 4648,4654 ----
Karsten Hopp 902bb6
  }
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
  /*
Karsten Hopp 902bb6
!  * Version of fopen() that may use UTF-16 file name.
Karsten Hopp 902bb6
   */
Karsten Hopp 902bb6
      FILE *
Karsten Hopp 902bb6
  mch_fopen(char *name, char *mode)
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4675,4682 ****
Karsten Hopp 902bb6
  	else if (newMode == 'b')
Karsten Hopp 902bb6
  	    _set_fmode(_O_BINARY);
Karsten Hopp 902bb6
  # endif
Karsten Hopp 902bb6
! 	wn = enc_to_ucs2(name, NULL);
Karsten Hopp 902bb6
! 	wm = enc_to_ucs2(mode, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL && wm != NULL)
Karsten Hopp 902bb6
  	    f = _wfopen(wn, wm);
Karsten Hopp 902bb6
  	vim_free(wn);
Karsten Hopp 902bb6
--- 4675,4682 ----
Karsten Hopp 902bb6
  	else if (newMode == 'b')
Karsten Hopp 902bb6
  	    _set_fmode(_O_BINARY);
Karsten Hopp 902bb6
  # endif
Karsten Hopp 902bb6
! 	wn = enc_to_utf16(name, NULL);
Karsten Hopp 902bb6
! 	wm = enc_to_utf16(mode, NULL);
Karsten Hopp 902bb6
  	if (wn != NULL && wm != NULL)
Karsten Hopp 902bb6
  	    f = _wfopen(wn, wm);
Karsten Hopp 902bb6
  	vim_free(wn);
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 4776,4783 ****
Karsten Hopp 902bb6
      int			len;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      /* Convert the file names to wide characters. */
Karsten Hopp 902bb6
!     fromw = enc_to_ucs2(from, NULL);
Karsten Hopp 902bb6
!     tow = enc_to_ucs2(to, NULL);
Karsten Hopp 902bb6
      if (fromw != NULL && tow != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* Open the file for reading. */
Karsten Hopp 902bb6
--- 4776,4783 ----
Karsten Hopp 902bb6
      int			len;
Karsten Hopp 902bb6
  
Karsten Hopp 902bb6
      /* Convert the file names to wide characters. */
Karsten Hopp 902bb6
!     fromw = enc_to_utf16(from, NULL);
Karsten Hopp 902bb6
!     tow = enc_to_utf16(to, NULL);
Karsten Hopp 902bb6
      if (fromw != NULL && tow != NULL)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	/* Open the file for reading. */
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 5122,5128 ****
Karsten Hopp 902bb6
      for (i = 0; i < used_file_count; ++i)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	idx = used_file_indexes[i];
Karsten Hopp 902bb6
! 	str = ucs2_to_enc(ArglistW[idx], NULL);
Karsten Hopp 902bb6
  	if (str != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  #ifdef FEAT_DIFF
Karsten Hopp 902bb6
--- 5122,5128 ----
Karsten Hopp 902bb6
      for (i = 0; i < used_file_count; ++i)
Karsten Hopp 902bb6
      {
Karsten Hopp 902bb6
  	idx = used_file_indexes[i];
Karsten Hopp 902bb6
! 	str = utf16_to_enc(ArglistW[idx], NULL);
Karsten Hopp 902bb6
  	if (str != NULL)
Karsten Hopp 902bb6
  	{
Karsten Hopp 902bb6
  #ifdef FEAT_DIFF
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/proto/os_mswin.pro	Sat May  5 19:07:50 2007
Karsten Hopp 902bb6
--- src/proto/os_mswin.pro	Thu Nov 20 16:41:00 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 22,35 ****
Karsten Hopp 902bb6
  int can_end_termcap_mode __ARGS((int give_msg));
Karsten Hopp 902bb6
  int mch_screenmode __ARGS((char_u *arg));
Karsten Hopp 902bb6
  int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
Karsten Hopp 902bb6
! int utf8_to_ucs2 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
Karsten Hopp 902bb6
! int ucs2_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
Karsten Hopp 902bb6
  void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
Karsten Hopp 902bb6
  void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
Karsten Hopp 902bb6
  int clip_mch_own_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
  void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
! short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp));
Karsten Hopp 902bb6
! char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp));
Karsten Hopp 902bb6
  void clip_mch_request_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
  void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
Karsten Hopp 902bb6
  void clip_mch_set_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
--- 22,35 ----
Karsten Hopp 902bb6
  int can_end_termcap_mode __ARGS((int give_msg));
Karsten Hopp 902bb6
  int mch_screenmode __ARGS((char_u *arg));
Karsten Hopp 902bb6
  int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
Karsten Hopp 902bb6
! int utf8_to_utf16 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
Karsten Hopp 902bb6
! int utf16_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
Karsten Hopp 902bb6
  void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
Karsten Hopp 902bb6
  void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
Karsten Hopp 902bb6
  int clip_mch_own_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
  void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
! short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp));
Karsten Hopp 902bb6
! char_u *utf16_to_enc __ARGS((short_u *str, int *lenp));
Karsten Hopp 902bb6
  void clip_mch_request_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
  void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
Karsten Hopp 902bb6
  void clip_mch_set_selection __ARGS((VimClipboard *cbd));
Karsten Hopp 902bb6
*** ../vim-7.2.048/src/version.c	Thu Nov 20 16:11:03 2008
Karsten Hopp 902bb6
--- src/version.c	Thu Nov 20 17:08:07 2008
Karsten Hopp 902bb6
***************
Karsten Hopp 902bb6
*** 678,679 ****
Karsten Hopp 902bb6
--- 678,681 ----
Karsten Hopp 902bb6
  {   /* Add new patch number below this line */
Karsten Hopp 902bb6
+ /**/
Karsten Hopp 902bb6
+     49,
Karsten Hopp 902bb6
  /**/
Karsten Hopp 902bb6
Karsten Hopp 902bb6
-- 
Karsten Hopp 902bb6
FIRST HEAD: All right! All right! We'll kill him first and then have tea and
Karsten Hopp 902bb6
            biscuits.
Karsten Hopp 902bb6
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 902bb6
Karsten Hopp 902bb6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 902bb6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 902bb6
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 902bb6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///