winex11.drv: Update a comment.
[wine.git] / dlls / user32 / lstr.c
blob3c24b8700c1b3b32c6736c852b0b6b9d9b719522
1 /*
2 * USER string functions
4 * Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
5 * Copyright 1996 Alexandre Julliard
6 * Copyright 1996 Marcus Meissner
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <ctype.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <string.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
32 #include "winuser.h"
33 #include "winerror.h"
35 #include "wine/exception.h"
38 /***********************************************************************
39 * CharNextExW (USER32.@)
41 LPWSTR WINAPI CharNextExW( WORD codepage, LPCWSTR ptr, DWORD flags )
43 /* doesn't make sense, there are no codepages for Unicode */
44 return NULL;
48 /***********************************************************************
49 * CharPrevExW (USER32.@)
51 LPSTR WINAPI CharPrevExW( WORD codepage, LPCWSTR start, LPCWSTR ptr, DWORD flags )
53 /* doesn't make sense, there are no codepages for Unicode */
54 return NULL;
58 /***********************************************************************
59 * CharToOemA (USER32.@)
61 BOOL WINAPI CharToOemA( LPCSTR s, LPSTR d )
63 if (!s || !d) return FALSE;
64 return CharToOemBuffA( s, d, strlen( s ) + 1 );
68 /***********************************************************************
69 * CharToOemBuffA (USER32.@)
71 BOOL WINAPI CharToOemBuffA( LPCSTR s, LPSTR d, DWORD len )
73 WCHAR *bufW;
75 if (!s || !d) return FALSE;
77 bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
78 if( bufW )
80 MultiByteToWideChar( CP_ACP, 0, s, len, bufW, len );
81 WideCharToMultiByte( CP_OEMCP, 0, bufW, len, d, len, NULL, NULL );
82 HeapFree( GetProcessHeap(), 0, bufW );
84 return TRUE;
88 /***********************************************************************
89 * CharToOemBuffW (USER32.@)
91 BOOL WINAPI CharToOemBuffW( LPCWSTR s, LPSTR d, DWORD len )
93 if (!s || !d) return FALSE;
94 WideCharToMultiByte( CP_OEMCP, 0, s, len, d, len, NULL, NULL );
95 return TRUE;
99 /***********************************************************************
100 * CharToOemW (USER32.@)
102 BOOL WINAPI CharToOemW( LPCWSTR s, LPSTR d )
104 if (!s || !d) return FALSE;
105 return CharToOemBuffW( s, d, lstrlenW( s ) + 1 );
109 /***********************************************************************
110 * OemToCharA (USER32.@)
112 BOOL WINAPI OemToCharA( LPCSTR s, LPSTR d )
114 if (!s || !d) return FALSE;
115 return OemToCharBuffA( s, d, strlen( s ) + 1 );
119 /***********************************************************************
120 * OemToCharBuffA (USER32.@)
122 BOOL WINAPI OemToCharBuffA( LPCSTR s, LPSTR d, DWORD len )
124 WCHAR *bufW;
126 if (!s || !d) return FALSE;
128 bufW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
129 if( bufW )
131 MultiByteToWideChar( CP_OEMCP, 0, s, len, bufW, len );
132 WideCharToMultiByte( CP_ACP, 0, bufW, len, d, len, NULL, NULL );
133 HeapFree( GetProcessHeap(), 0, bufW );
135 return TRUE;
139 /***********************************************************************
140 * OemToCharBuffW (USER32.@)
142 BOOL WINAPI OemToCharBuffW( LPCSTR s, LPWSTR d, DWORD len )
144 if (!s || !d) return FALSE;
145 MultiByteToWideChar( CP_OEMCP, MB_PRECOMPOSED | MB_USEGLYPHCHARS, s, len, d, len );
146 return TRUE;
150 /***********************************************************************
151 * OemToCharW (USER32.@)
153 BOOL WINAPI OemToCharW( LPCSTR s, LPWSTR d )
155 if (!s || !d) return FALSE;
156 return OemToCharBuffW( s, d, strlen( s ) + 1 );