Changeset 1871 for trunk/src/kernel32/unicode.cpp
- Timestamp:
- Nov 29, 1999, 12:23:46 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/unicode.cpp
r1838 r1871 1 /* $Id: unicode.cpp,v 1.1 5 1999-11-25 19:19:57 sandervlExp $ */1 /* $Id: unicode.cpp,v 1.16 1999-11-28 23:23:46 bird Exp $ */ 2 2 3 3 /* … … 72 72 */ 73 73 INT WINAPI MultiByteToWideChar(UINT page, DWORD flags, 74 74 LPCSTR src, INT srclen, 75 75 LPWSTR dst, INT dstlen) 76 76 { … … 78 78 79 79 if (srclen == -1) 80 80 srclen = lstrlenA(src)+1; 81 81 if (!dstlen || !dst) 82 82 return srclen; 83 83 84 84 ret = srclen; 85 85 while (srclen && dstlen) { 86 87 88 86 *dst = (WCHAR)(unsigned char)*src; 87 dst++; src++; 88 dstlen--; srclen--; 89 89 } 90 90 if (!dstlen && srclen) { 91 92 91 SetLastError(ERROR_INSUFFICIENT_BUFFER); 92 return 0; 93 93 } 94 94 return ret; … … 106 106 * dstlen [in] Length of destination buffer 107 107 * defchar [in] Default character to use for conversion if no exact 108 * 108 * conversion can be made 109 109 * used [out] Set if default character was used in the conversion 110 110 * … … 128 128 */ 129 129 INT WIN32API WideCharToMultiByte(UINT page, DWORD flags, LPCWSTR src, 130 131 130 INT srclen,LPSTR dst, INT dstlen, 131 LPCSTR defchar, BOOL *used) 132 132 { 133 133 int count = 0; … … 137 137 138 138 if ((!src) || ((!dst) && (!dont_copy)) ) 139 { 140 141 } 142 139 { SetLastError(ERROR_INVALID_PARAMETER); 140 return 0; 141 } 142 143 143 if (page!=GetACP() && page!=CP_OEMCP && page!=CP_ACP) 144 144 dprintf(("WideCharToMultiByte, Conversion in CP %d not supported\n",page)); 145 145 #if 0 146 146 if (flags) 147 147 dprintf(("WideCharToMultiByte, flags %lx not supported\n",flags)); 148 148 #endif 149 149 if(used) 150 150 *used=0; 151 151 if (srclen == -1) 152 152 { 153 154 153 srclen = lstrlenW(src)+1; 154 care_for_eos=1; 155 155 } 156 156 while(srclen && (dont_copy || dstlen)) 157 157 { 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 158 if(!dont_copy){ 159 if(*src<256) 160 *dst = *src; 161 else 162 { 163 /* ??? The WC_DEFAULTCHAR flag only gets used in 164 * combination with the WC_COMPOSITECHECK flag or at 165 * least this is what it seems from using the function 166 * on NT4.0 in combination with reading the documentation. 167 */ 168 *dst = defchar ? *defchar : '?'; 169 if(used)*used=1; 170 } 171 dstlen--; 172 dst++; 173 } 174 count++; 175 srclen--; 176 if((!*src) && care_for_eos) { 177 eos = 1; 178 break; 179 } 180 src++; 181 181 } 182 182 if (dont_copy) 183 183 return count; 184 184 185 185 if (!eos && srclen > 0) { 186 187 186 SetLastError(ERROR_INSUFFICIENT_BUFFER); 187 return 0; 188 188 } 189 189 return count; … … 204 204 // returns string length 205 205 //****************************************************************************** 206 int WIN32API UnicodeToAsciiN( WCHAR *ustring, char *astring, int unilen)206 int WIN32API UnicodeToAsciiN(LPCWSTR ustring, char *astring, int unilen) 207 207 { 208 208 int i; … … 264 264 // returns length of ascii string 265 265 //****************************************************************************** 266 int WIN32API UnicodeToAscii( WCHAR *ustring, char *astring)266 int WIN32API UnicodeToAscii(LPCWSTR ustring, char *astring) 267 267 { 268 268 /* forward to function with len parameter */ … … 273 273 // returns pointer to ascii string 274 274 //****************************************************************************** 275 char * WIN32API UnicodeToAsciiString( WCHAR *ustring)275 char * WIN32API UnicodeToAsciiString(LPCWSTR ustring) 276 276 { 277 277 char *astring; … … 285 285 //****************************************************************************** 286 286 //****************************************************************************** 287 char * WIN32API UnicodeToAsciiStringN( WCHAR *ustring, ULONG length)287 char * WIN32API UnicodeToAsciiStringN(LPCWSTR ustring, ULONG length) 288 288 { 289 289 char *astring; … … 299 299 // returns pointer to unicode string 300 300 //****************************************************************************** 301 WCHAR * WIN32API AsciiToUnicodeString(c har *astring)301 WCHAR * WIN32API AsciiToUnicodeString(const char *astring) 302 302 { 303 303 WCHAR *ustring; … … 322 322 // asciilen: max length of unicode buffer (including end 0) 323 323 //****************************************************************************** 324 void WIN32API AsciiToUnicodeN(c har *ascii, WCHAR *unicode, int asciilen)324 void WIN32API AsciiToUnicodeN(const char *ascii, WCHAR *unicode, int asciilen) 325 325 { 326 326 int rc; … … 329 329 size_t in_bytes_left; 330 330 size_t num_subs; 331 UniChar * out_buf;332 c har* in_buf;331 UniChar * out_buf; 332 const char * in_buf; 333 333 334 334 … … 387 387 // Copies the full string from ascii to unicode 388 388 //****************************************************************************** 389 void WIN32API AsciiToUnicode(c har *ascii, WCHAR *unicode)389 void WIN32API AsciiToUnicode(const char *ascii, WCHAR *unicode) 390 390 { 391 391 /* achimha for security, strlen might trap if garbage in */
Note:
See TracChangeset
for help on using the changeset viewer.