2009-12-14 00:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/win_misc.c
    ! Fixed WIN_ANSITOWIDE() and WIN_WIDETOANSI() to return string with
      proper length in all cases.
      Peer-review me pls.
This commit is contained in:
Viktor Szakats
2009-12-13 23:07:28 +00:00
parent b057507e3c
commit 507e9d6ca9
2 changed files with 19 additions and 5 deletions

View File

@@ -17,6 +17,12 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-14 00:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_misc.c
! Fixed WIN_ANSITOWIDE() and WIN_WIDETOANSI() to return string with
proper length in all cases.
Peer-review me pls.
2009-12-13 22:47 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/compiler/hbmain.c
* src/compiler/cmdcheck.c
@@ -198,7 +204,7 @@
after conversion to/from UNICODE can be different then
original number of chars, i.e. multibyte characters
can be replaced by single Unicode character or one Unicode
character may use few bytes representation.
character may use few bytes representation. [DONE]
2009-12-12 12:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbqt/hbqt_hbqmainwindow.cpp

View File

@@ -186,17 +186,25 @@ HB_FUNC( WIN_GETCOMMANDLINEPARAM )
HB_FUNC( WIN_ANSITOWIDE )
{
HB_SIZE nLen = hb_parclen( 1 );
BSTR wString = hb_mbntowc( hb_parcx( 1 ), nLen );
LPCSTR lpSrcMB = hb_parcx( 1 );
DWORD dwLength = MultiByteToWideChar( CP_ACP, 0, lpSrcMB, ( int ) nLen, NULL, 0 );
LPWSTR lpDstWide = ( LPWSTR ) hb_xgrab( ( dwLength + 1 ) * sizeof( wchar_t ) );
hb_retclen_buffer( ( char * ) wString, nLen * sizeof( wchar_t ) );
MultiByteToWideChar( CP_ACP, 0, lpSrcMB, ( int ) nLen, lpDstWide, dwLength + 1 );
hb_retclen_buffer( ( char * ) lpDstWide, dwLength * sizeof( wchar_t ) );
}
HB_FUNC( WIN_WIDETOANSI )
{
HB_SIZE nLen = hb_parclen( 1 );
char * cString = hb_wcntomb( ( wchar_t * ) hb_parcx( 1 ), nLen );
LPCWSTR lpSrcWide = ( LPCWSTR ) hb_parcx( 1 );
DWORD dwLength = WideCharToMultiByte( CP_ACP, 0, lpSrcWide, ( int ) nLen, NULL, 0, NULL, NULL ) / sizeof( wchar_t );
LPSTR lpDstMB = ( LPSTR ) hb_xgrab( dwLength + 1 );
hb_retclen_buffer( cString, nLen / sizeof( wchar_t ) );
WideCharToMultiByte( CP_ACP, 0, lpSrcWide, ( int ) nLen, lpDstMB, dwLength + 1, NULL, NULL );
hb_retclen_buffer( lpDstMB, ( HB_SIZE ) dwLength );
}
HB_FUNC( WIN_N2P )