Ignore:
Timestamp:
Feb 19, 2004, 2:03:07 PM (22 years ago)
Author:
sandervl
Message:

DBCS fixes for console & resource functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/conbuffer.cpp

    r10010 r10471  
    1 /* $Id: conbuffer.cpp,v 1.19 2003-04-11 12:08:35 sandervl Exp $ */
     1/* $Id: conbuffer.cpp,v 1.20 2004-02-19 13:03:05 sandervl Exp $ */
    22
    33/*
     
    24982498}
    24992499
    2500 
    25012500/*****************************************************************************
    25022501 * Name      : DWORD HMDeviceConsoleBufferClass::WriteConsoleW
     
    25242523  DWORD          rc;
    25252524  LPSTR          pszAscii;
     2525  int            alen;
    25262526
    25272527#ifdef DEBUG_LOCAL2
     
    25342534#endif
    25352535
     2536  alen = WideCharToMultiByte( GetConsoleCP(), 0, (LPCWSTR)lpvBuffer, cchToWrite, 0, 0, 0, 0 );
    25362537  /* Ascii -> unicode translation */
    2537   pszAscii = (LPSTR)HEAP_malloc(cchToWrite+1);
     2538  pszAscii = (LPSTR)HEAP_malloc(( alen + 1 ) * sizeof( WCHAR ));
    25382539  if (pszAscii == NULL)
    25392540     return ERROR_NOT_ENOUGH_MEMORY;
    25402541
    2541   lstrcpynWtoA(pszAscii, (LPWSTR)lpvBuffer, cchToWrite+1);
     2542  WideCharToMultiByte( GetConsoleCP(), 0, (LPWSTR)lpvBuffer, cchToWrite, pszAscii, alen, 0, 0 );
     2543  pszAscii[ alen ] = 0;
    25422544
    25432545  /* simply forward the request to that routine */
    25442546  rc = HMDeviceConsoleBufferClass::WriteFile(pHMHandleData,
    25452547                                             pszAscii,
    2546                                              cchToWrite,
     2548                                             alen,
    25472549                                             lpcchWritten,
    25482550                                             NULL, NULL);
    25492551
     2552  *lpcchWritten = MultiByteToWideChar( GetConsoleCP(), 0, pszAscii, *lpcchWritten, 0, 0 );
    25502553  // free memory again
    25512554  HEAP_free(pszAscii);
Note: See TracChangeset for help on using the changeset viewer.