2000-08-04 06:21:02 +02:00
|
|
|
/*
|
2000-08-06 04:42:46 +02:00
|
|
|
* USER string functions
|
2000-08-04 06:21:02 +02:00
|
|
|
*
|
|
|
|
* Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
|
2000-08-06 04:42:46 +02:00
|
|
|
* Copyright 1996 Alexandre Julliard
|
2000-08-04 06:21:02 +02:00
|
|
|
* Copyright 1996 Marcus Meissner
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-08-04 06:21:02 +02:00
|
|
|
*/
|
|
|
|
|
2000-08-06 04:42:46 +02:00
|
|
|
#include <ctype.h>
|
2000-08-04 06:21:02 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2001-01-22 03:17:29 +01:00
|
|
|
#include <string.h>
|
2000-08-04 06:21:02 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-08-04 06:21:02 +02:00
|
|
|
#include "winbase.h"
|
2016-03-29 13:40:57 +02:00
|
|
|
#include "winnls.h"
|
2005-03-29 15:15:44 +02:00
|
|
|
#include "winuser.h"
|
2001-04-16 22:27:16 +02:00
|
|
|
#include "winerror.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
|
2001-04-16 22:27:16 +02:00
|
|
|
|
2000-08-06 04:42:46 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CharNextExW (USER32.@)
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI CharNextExW( WORD codepage, LPCWSTR ptr, DWORD flags )
|
|
|
|
{
|
|
|
|
/* doesn't make sense, there are no codepages for Unicode */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CharPrevExW (USER32.@)
|
|
|
|
*/
|
|
|
|
LPSTR WINAPI CharPrevExW( WORD codepage, LPCWSTR start, LPCWSTR ptr, DWORD flags )
|
|
|
|
{
|
|
|
|
/* doesn't make sense, there are no codepages for Unicode */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CharToOemA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CharToOemA( LPCSTR s, LPSTR d )
|
|
|
|
{
|
2016-07-08 05:11:42 +02:00
|
|
|
if (!s || !d) return FALSE;
|
2000-08-06 04:42:46 +02:00
|
|
|
return CharToOemBuffA( s, d, strlen( s ) + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CharToOemBuffA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CharToOemBuffA( LPCSTR s, LPSTR d, DWORD len )
|
|
|
|
{
|
|
|
|
WCHAR *bufW;
|
|
|
|
|
2016-07-08 05:11:42 +02:00
|
|
|
if (!s || !d) return FALSE;
|
|
|
|
|
2000-08-06 04:42:46 +02:00
|
|
|
bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
if( bufW )
|
|
|
|
{
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, s, len, bufW, len );
|
|
|
|
WideCharToMultiByte( CP_OEMCP, 0, bufW, len, d, len, NULL, NULL );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bufW );
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CharToOemBuffW (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CharToOemBuffW( LPCWSTR s, LPSTR d, DWORD len )
|
|
|
|
{
|
2016-07-08 05:12:11 +02:00
|
|
|
if (!s || !d) return FALSE;
|
2000-08-06 04:42:46 +02:00
|
|
|
WideCharToMultiByte( CP_OEMCP, 0, s, len, d, len, NULL, NULL );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CharToOemW (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CharToOemW( LPCWSTR s, LPSTR d )
|
|
|
|
{
|
2016-07-08 05:12:11 +02:00
|
|
|
if (!s || !d) return FALSE;
|
2016-03-29 13:40:57 +02:00
|
|
|
return CharToOemBuffW( s, d, lstrlenW( s ) + 1 );
|
2000-08-06 04:42:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OemToCharA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI OemToCharA( LPCSTR s, LPSTR d )
|
|
|
|
{
|
2016-07-08 05:11:42 +02:00
|
|
|
if (!s || !d) return FALSE;
|
2000-08-06 04:42:46 +02:00
|
|
|
return OemToCharBuffA( s, d, strlen( s ) + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OemToCharBuffA (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI OemToCharBuffA( LPCSTR s, LPSTR d, DWORD len )
|
|
|
|
{
|
|
|
|
WCHAR *bufW;
|
|
|
|
|
2016-07-08 05:11:42 +02:00
|
|
|
if (!s || !d) return FALSE;
|
|
|
|
|
2000-08-06 04:42:46 +02:00
|
|
|
bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
if( bufW )
|
|
|
|
{
|
|
|
|
MultiByteToWideChar( CP_OEMCP, 0, s, len, bufW, len );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, bufW, len, d, len, NULL, NULL );
|
|
|
|
HeapFree( GetProcessHeap(), 0, bufW );
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OemToCharBuffW (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI OemToCharBuffW( LPCSTR s, LPWSTR d, DWORD len )
|
|
|
|
{
|
2016-07-08 05:12:11 +02:00
|
|
|
if (!s || !d) return FALSE;
|
2016-09-22 12:12:37 +02:00
|
|
|
MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED | MB_USEGLYPHCHARS, s, len, d, len );
|
2000-08-06 04:42:46 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OemToCharW (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI OemToCharW( LPCSTR s, LPWSTR d )
|
|
|
|
{
|
2016-07-08 05:12:11 +02:00
|
|
|
if (!s || !d) return FALSE;
|
2000-08-06 04:42:46 +02:00
|
|
|
return OemToCharBuffW( s, d, strlen( s ) + 1 );
|
|
|
|
}
|