@@ -3107,21 +3107,51 @@ mch_nodetype(char_u *name)
31073107{
31083108 HANDLE hFile ;
31093109 int type ;
3110+ #ifdef FEAT_MBYTE
3111+ WCHAR * wn = NULL ;
3112+ #endif
31103113
31113114 /* We can't open a file with a name "\\.\con" or "\\.\prn" and trying to
31123115 * read from it later will cause Vim to hang. Thus return NODE_WRITABLE
31133116 * here. */
31143117 if (STRNCMP (name , "\\\\.\\" , 4 ) == 0 )
31153118 return NODE_WRITABLE ;
31163119
3117- hFile = CreateFile (name , /* file name */
3118- GENERIC_WRITE , /* access mode */
3119- 0 , /* share mode */
3120- NULL , /* security descriptor */
3121- OPEN_EXISTING , /* creation disposition */
3122- 0 , /* file attributes */
3123- NULL ); /* handle to template file */
3120+ #ifdef FEAT_MBYTE
3121+ if (enc_codepage >= 0 && (int )GetACP () != enc_codepage )
3122+ {
3123+ wn = enc_to_utf16 (name , NULL );
3124+ if (wn != NULL )
3125+ {
3126+ hFile = CreateFileW (wn , /* file name */
3127+ GENERIC_WRITE , /* access mode */
3128+ 0 , /* share mode */
3129+ NULL , /* security descriptor */
3130+ OPEN_EXISTING , /* creation disposition */
3131+ 0 , /* file attributes */
3132+ NULL ); /* handle to template file */
3133+ if (hFile == INVALID_HANDLE_VALUE
3134+ && GetLastError () == ERROR_CALL_NOT_IMPLEMENTED )
3135+ {
3136+ /* Retry with non-wide function (for Windows 98). */
3137+ vim_free (wn );
3138+ wn = NULL ;
3139+ }
3140+ }
3141+ }
3142+ if (wn == NULL )
3143+ #endif
3144+ hFile = CreateFile (name , /* file name */
3145+ GENERIC_WRITE , /* access mode */
3146+ 0 , /* share mode */
3147+ NULL , /* security descriptor */
3148+ OPEN_EXISTING , /* creation disposition */
3149+ 0 , /* file attributes */
3150+ NULL ); /* handle to template file */
31243151
3152+ #ifdef FEAT_MBYTE
3153+ vim_free (wn );
3154+ #endif
31253155 if (hFile == INVALID_HANDLE_VALUE )
31263156 return NODE_NORMAL ;
31273157
0 commit comments