| 1 | /* $Id: heapstring.cpp,v 1.15 1999-10-14 17:15:26 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 5 | *
|
|---|
| 6 | * Win32 compatibility string functions for OS/2
|
|---|
| 7 | *
|
|---|
| 8 | * Copyright 1999 Patrick Haller
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | /*****************************************************************************
|
|---|
| 12 | * Includes *
|
|---|
| 13 | *****************************************************************************/
|
|---|
| 14 |
|
|---|
| 15 | #include <odin.h>
|
|---|
| 16 | #include <odinwrap.h>
|
|---|
| 17 | #include <os2sel.h>
|
|---|
| 18 |
|
|---|
| 19 | #include <os2win.h>
|
|---|
| 20 | #include <stdlib.h>
|
|---|
| 21 | #include <string.h>
|
|---|
| 22 | #include <winnls.h>
|
|---|
| 23 | #include <unicode.h>
|
|---|
| 24 | #include <ctype.h>
|
|---|
| 25 | #include <wcstr.h>
|
|---|
| 26 | #include "heap.h"
|
|---|
| 27 | #include <heapstring.h>
|
|---|
| 28 | #include "misc.h"
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | /*****************************************************************************
|
|---|
| 32 | * Defines *
|
|---|
| 33 | *****************************************************************************/
|
|---|
| 34 |
|
|---|
| 35 | ODINDEBUGCHANNEL(KERNEL32-HEAPSTRING)
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | /*****************************************************************************
|
|---|
| 39 | * Name :
|
|---|
| 40 | * Purpose :
|
|---|
| 41 | * Parameters:
|
|---|
| 42 | * Variables :
|
|---|
| 43 | * Result :
|
|---|
| 44 | * Remark :
|
|---|
| 45 | * Status :
|
|---|
| 46 | *
|
|---|
| 47 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 48 | *****************************************************************************/
|
|---|
| 49 |
|
|---|
| 50 | static UconvObject uconv_object = NULL;
|
|---|
| 51 |
|
|---|
| 52 | static BOOL getUconvObject( void )
|
|---|
| 53 | {
|
|---|
| 54 | int rc;
|
|---|
| 55 | BOOL ret;
|
|---|
| 56 |
|
|---|
| 57 | if ( uconv_object )
|
|---|
| 58 | ret = TRUE;
|
|---|
| 59 | else
|
|---|
| 60 | {
|
|---|
| 61 | rc = UniCreateUconvObject( (UniChar*)L"",
|
|---|
| 62 | &uconv_object );
|
|---|
| 63 | if ( rc == ULS_SUCCESS )
|
|---|
| 64 | ret = TRUE;
|
|---|
| 65 | else
|
|---|
| 66 | {
|
|---|
| 67 | uconv_object = NULL; // to make sure
|
|---|
| 68 | return FALSE;
|
|---|
| 69 | }
|
|---|
| 70 | dprintf(("KERNEL32: HeapString: UniCreateUconvObject(%d)\n",
|
|---|
| 71 | rc));
|
|---|
| 72 | }
|
|---|
| 73 | return ret;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | /*****************************************************************************
|
|---|
| 78 | * Name :
|
|---|
| 79 | * Purpose :
|
|---|
| 80 | * Parameters:
|
|---|
| 81 | * Variables :
|
|---|
| 82 | * Result :
|
|---|
| 83 | * Remark :
|
|---|
| 84 | * Status :
|
|---|
| 85 | *
|
|---|
| 86 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 87 | *****************************************************************************/
|
|---|
| 88 |
|
|---|
| 89 | int WIN32API lstrlenA(LPCSTR arg1)
|
|---|
| 90 | {
|
|---|
| 91 | dprintf(("KERNEL32: lstrlenA(%s)\n",
|
|---|
| 92 | arg1));
|
|---|
| 93 |
|
|---|
| 94 | return O32_lstrlen(arg1);
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | /*****************************************************************************
|
|---|
| 99 | * Name :
|
|---|
| 100 | * Purpose :
|
|---|
| 101 | * Parameters:
|
|---|
| 102 | * Variables :
|
|---|
| 103 | * Result :
|
|---|
| 104 | * Remark :
|
|---|
| 105 | * Status :
|
|---|
| 106 | *
|
|---|
| 107 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 108 | *****************************************************************************/
|
|---|
| 109 |
|
|---|
| 110 | int WIN32API lstrlenW(LPCWSTR arg1)
|
|---|
| 111 | {
|
|---|
| 112 | int rc;
|
|---|
| 113 |
|
|---|
| 114 | rc = UniStrlen( (UniChar*)arg1);
|
|---|
| 115 | dprintf(("KERNEL32: lstrlenW(%08xh) returns %d\n",
|
|---|
| 116 | arg1,
|
|---|
| 117 | rc));
|
|---|
| 118 | return rc;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | /*****************************************************************************
|
|---|
| 123 | * Name :
|
|---|
| 124 | * Purpose :
|
|---|
| 125 | * Parameters:
|
|---|
| 126 | * Variables :
|
|---|
| 127 | * Result :
|
|---|
| 128 | * Remark :
|
|---|
| 129 | * Status :
|
|---|
| 130 | *
|
|---|
| 131 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 132 | *****************************************************************************/
|
|---|
| 133 |
|
|---|
| 134 | LPSTR WIN32API lstrcatA(LPSTR arg1, LPCSTR arg2)
|
|---|
| 135 | {
|
|---|
| 136 | dprintf(("KERNEL32: lstrcat(%s,%s)\n",
|
|---|
| 137 | arg1,
|
|---|
| 138 | arg2));
|
|---|
| 139 |
|
|---|
| 140 | return O32_lstrcat(arg1, arg2);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | /*****************************************************************************
|
|---|
| 145 | * Name :
|
|---|
| 146 | * Purpose :
|
|---|
| 147 | * Parameters:
|
|---|
| 148 | * Variables :
|
|---|
| 149 | * Result :
|
|---|
| 150 | * Remark :
|
|---|
| 151 | * Status :
|
|---|
| 152 | *
|
|---|
| 153 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 154 | *****************************************************************************/
|
|---|
| 155 |
|
|---|
| 156 | LPWSTR WIN32API lstrcatW(LPWSTR arg1, LPCWSTR arg2)
|
|---|
| 157 | {
|
|---|
| 158 | dprintf(("KERNEL32: OS2lstrcatW(%08xh,%08xh)\n",
|
|---|
| 159 | arg1,
|
|---|
| 160 | arg2));
|
|---|
| 161 |
|
|---|
| 162 | UniStrcat( (UniChar*) arg1, (UniChar*) arg2 );
|
|---|
| 163 | return arg1;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 | /*****************************************************************************
|
|---|
| 168 | * Name :
|
|---|
| 169 | * Purpose :
|
|---|
| 170 | * Parameters:
|
|---|
| 171 | * Variables :
|
|---|
| 172 | * Result :
|
|---|
| 173 | * Remark :
|
|---|
| 174 | * Status :
|
|---|
| 175 | *
|
|---|
| 176 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 177 | *****************************************************************************/
|
|---|
| 178 |
|
|---|
| 179 | int WIN32API lstrcmpA(LPCSTR arg1, LPCSTR arg2)
|
|---|
| 180 | {
|
|---|
| 181 | dprintf(("KERNEL32: OS2lstrcmpA(%s,%s)\n",
|
|---|
| 182 | arg1,
|
|---|
| 183 | arg2));
|
|---|
| 184 |
|
|---|
| 185 | return O32_lstrcmp(arg1, arg2);
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | /*****************************************************************************
|
|---|
| 190 | * Name :
|
|---|
| 191 | * Purpose :
|
|---|
| 192 | * Parameters:
|
|---|
| 193 | * Variables :
|
|---|
| 194 | * Result :
|
|---|
| 195 | * Remark :
|
|---|
| 196 | * Status :
|
|---|
| 197 | *
|
|---|
| 198 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 199 | *****************************************************************************/
|
|---|
| 200 |
|
|---|
| 201 | int WIN32API lstrncmpA(LPCSTR arg1, LPCSTR arg2, int l)
|
|---|
| 202 | {
|
|---|
| 203 | dprintf(("KERNEL32: OS2lstrncmpA(%s,%s,%d)\n",
|
|---|
| 204 | arg1,
|
|---|
| 205 | arg2,
|
|---|
| 206 | l));
|
|---|
| 207 |
|
|---|
| 208 | return strncmp(arg1, arg2, l);
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | /*****************************************************************************
|
|---|
| 212 | * Name : lstrncmpiA
|
|---|
| 213 | * Purpose :
|
|---|
| 214 | * Parameters:
|
|---|
| 215 | * Variables :
|
|---|
| 216 | * Result :
|
|---|
| 217 | * Remark :
|
|---|
| 218 | * Status :
|
|---|
| 219 | *
|
|---|
| 220 | * Author : Przemyslaw Dobrowolski
|
|---|
| 221 | *****************************************************************************/
|
|---|
| 222 | INT WINAPI lstrncmpiA( LPCSTR str1, LPCSTR str2, INT n )
|
|---|
| 223 | {
|
|---|
| 224 | INT firstch,lastch;
|
|---|
| 225 | INT result = 0;
|
|---|
| 226 |
|
|---|
| 227 | if (n)
|
|---|
| 228 | {
|
|---|
| 229 | do
|
|---|
| 230 | {
|
|---|
| 231 | firstch = tolower(*str1);
|
|---|
| 232 | lastch = tolower(*str2);
|
|---|
| 233 | str1++;
|
|---|
| 234 | str2++;
|
|---|
| 235 | } while (--n && str1 && str2 && firstch == lastch);
|
|---|
| 236 |
|
|---|
| 237 | result = firstch - lastch;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | return(result);
|
|---|
| 241 | }
|
|---|
| 242 | //TODO: Don't know if this is completely correct
|
|---|
| 243 | int WIN32API lstrncmpiW(LPCWSTR str1, LPCWSTR str2, int n)
|
|---|
| 244 | {
|
|---|
| 245 | INT firstch,lastch;
|
|---|
| 246 | INT result = 0;
|
|---|
| 247 |
|
|---|
| 248 | if (n)
|
|---|
| 249 | {
|
|---|
| 250 | do
|
|---|
| 251 | {
|
|---|
| 252 | firstch = tolower((char)*str1);
|
|---|
| 253 | lastch = tolower((char)*str2);
|
|---|
| 254 | str1++;
|
|---|
| 255 | str2++;
|
|---|
| 256 | } while (--n && str1 && str2 && firstch == lastch);
|
|---|
| 257 |
|
|---|
| 258 | result = firstch - lastch;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | return(result);
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | /*****************************************************************************
|
|---|
| 265 | * Name :
|
|---|
| 266 | * Purpose :
|
|---|
| 267 | * Parameters:
|
|---|
| 268 | * Variables :
|
|---|
| 269 | * Result :
|
|---|
| 270 | * Remark :
|
|---|
| 271 | * Status :
|
|---|
| 272 | *
|
|---|
| 273 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 274 | *****************************************************************************/
|
|---|
| 275 |
|
|---|
| 276 | int WIN32API lstrcmpW(LPCWSTR arg1, LPCWSTR arg2)
|
|---|
| 277 | {
|
|---|
| 278 | dprintf(("KERNEL32: lstrcmpW (%08xh-%ls, %08xh-%ls)\n",
|
|---|
| 279 | arg1,
|
|---|
| 280 | arg1,
|
|---|
| 281 | arg2,
|
|---|
| 282 | arg2));
|
|---|
| 283 |
|
|---|
| 284 | if(arg1 == NULL)
|
|---|
| 285 | return -1;
|
|---|
| 286 | if(arg2 == NULL)
|
|---|
| 287 | return 1;
|
|---|
| 288 |
|
|---|
| 289 | return wcscmp( (wchar_t*)arg1,
|
|---|
| 290 | (wchar_t*)arg2 );
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 | /*****************************************************************************
|
|---|
| 295 | * Name :
|
|---|
| 296 | * Purpose :
|
|---|
| 297 | * Parameters:
|
|---|
| 298 | * Variables :
|
|---|
| 299 | * Result :
|
|---|
| 300 | * Remark :
|
|---|
| 301 | * Status :
|
|---|
| 302 | *
|
|---|
| 303 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 304 | *****************************************************************************/
|
|---|
| 305 |
|
|---|
| 306 | int WIN32API lstrncmpW(LPCWSTR arg1, LPCWSTR arg2, int l)
|
|---|
| 307 | {
|
|---|
| 308 | dprintf(("KERNEL32: OS2lstrncmpW(%08xh,%08xh,%d)\n",
|
|---|
| 309 | arg1,
|
|---|
| 310 | arg2,
|
|---|
| 311 | l));
|
|---|
| 312 |
|
|---|
| 313 | return wcsncmp((wchar_t*)arg1,
|
|---|
| 314 | (wchar_t*)arg2,
|
|---|
| 315 | l);
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | /*****************************************************************************
|
|---|
| 319 | * Name :
|
|---|
| 320 | * Purpose :
|
|---|
| 321 | * Parameters:
|
|---|
| 322 | * Variables :
|
|---|
| 323 | * Result :
|
|---|
| 324 | * Remark :
|
|---|
| 325 | * Status :
|
|---|
| 326 | *
|
|---|
| 327 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 328 | *****************************************************************************/
|
|---|
| 329 |
|
|---|
| 330 | ODINFUNCTION2(LPSTR,lstrcpyA,LPSTR, dest,
|
|---|
| 331 | LPCSTR,src)
|
|---|
| 332 | {
|
|---|
| 333 | if ( (src == NULL) || (dest == NULL) ) // stupid parameter checking
|
|---|
| 334 | return NULL;
|
|---|
| 335 |
|
|---|
| 336 | return O32_lstrcpy(dest, src);
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 | /*****************************************************************************
|
|---|
| 341 | * Name :
|
|---|
| 342 | * Purpose :
|
|---|
| 343 | * Parameters:
|
|---|
| 344 | * Variables :
|
|---|
| 345 | * Result :
|
|---|
| 346 | * Remark :
|
|---|
| 347 | * Status :
|
|---|
| 348 | *
|
|---|
| 349 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 350 | *****************************************************************************/
|
|---|
| 351 |
|
|---|
| 352 | ODINFUNCTION2(LPWSTR,lstrcpyW,LPWSTR, dest,
|
|---|
| 353 | LPCWSTR,src)
|
|---|
| 354 | {
|
|---|
| 355 | if ( (src == NULL) || (dest == NULL) ) // stupid parameter checking
|
|---|
| 356 | return NULL;
|
|---|
| 357 |
|
|---|
| 358 | UniStrcpy( (UniChar*)dest,
|
|---|
| 359 | (UniChar*)src );
|
|---|
| 360 | return dest;
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 | /*****************************************************************************
|
|---|
| 365 | * Name :
|
|---|
| 366 | * Purpose :
|
|---|
| 367 | * Parameters:
|
|---|
| 368 | * Variables :
|
|---|
| 369 | * Result :
|
|---|
| 370 | * Remark :
|
|---|
| 371 | * Status :
|
|---|
| 372 | *
|
|---|
| 373 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 374 | *****************************************************************************/
|
|---|
| 375 |
|
|---|
| 376 | LPSTR WIN32API lstrcpynA(LPSTR arg1, LPCSTR arg2, int arg3)
|
|---|
| 377 | {
|
|---|
| 378 | register LPSTR p1 = arg1;
|
|---|
| 379 | register LPSTR p2 = (LPSTR)arg2;
|
|---|
| 380 |
|
|---|
| 381 | dprintf(("KERNEL32: OS2lstrcpyA(%08xh, %08xh, %08xh)\n",
|
|---|
| 382 | arg1,
|
|---|
| 383 | arg2,
|
|---|
| 384 | arg3));
|
|---|
| 385 |
|
|---|
| 386 | //PH: looks like either \0 or arg3 terminate the copy
|
|---|
| 387 | //return strncpy(arg1, arg2, arg3);
|
|---|
| 388 | arg3--; // pre-decrement to avoid exceeding buffer length
|
|---|
| 389 | // results in better code than (arg1 > 1)
|
|---|
| 390 |
|
|---|
| 391 | for (;*p2 && arg3; arg3--)
|
|---|
| 392 | *p1++ = *p2++;
|
|---|
| 393 |
|
|---|
| 394 | *p1 = 0; //CB: copy arg-1, set end 0
|
|---|
| 395 |
|
|---|
| 396 | return arg1;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 | /*****************************************************************************
|
|---|
| 401 | * Name :
|
|---|
| 402 | * Purpose :
|
|---|
| 403 | * Parameters:
|
|---|
| 404 | * Variables :
|
|---|
| 405 | * Result :
|
|---|
| 406 | * Remark :
|
|---|
| 407 | * Status :
|
|---|
| 408 | *
|
|---|
| 409 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 410 | *****************************************************************************/
|
|---|
| 411 |
|
|---|
| 412 | LPWSTR WIN32API lstrcpynW(LPWSTR dest, LPCWSTR src, int arg3)
|
|---|
| 413 | {
|
|---|
| 414 | dprintf(("KERNEL32: lstrcpynW(%08xh,%08xh,%08xh)",
|
|---|
| 415 | dest,
|
|---|
| 416 | src,
|
|---|
| 417 | arg3));
|
|---|
| 418 |
|
|---|
| 419 | if (arg3 == 0)
|
|---|
| 420 | return NULL;
|
|---|
| 421 |
|
|---|
| 422 | UniStrncpy( (UniChar*)dest,
|
|---|
| 423 | (UniChar*)src,
|
|---|
| 424 | arg3-1); //CB: copy arg3-1 characters
|
|---|
| 425 | dest[arg3-1] = 0; //CB: set end
|
|---|
| 426 | return dest;
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 | /*****************************************************************************
|
|---|
| 431 | * Name :
|
|---|
| 432 | * Purpose :
|
|---|
| 433 | * Parameters:
|
|---|
| 434 | * Variables :
|
|---|
| 435 | * Result :
|
|---|
| 436 | * Remark :
|
|---|
| 437 | * Status :
|
|---|
| 438 | *
|
|---|
| 439 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 440 | *****************************************************************************/
|
|---|
| 441 |
|
|---|
| 442 | int WIN32API lstrcmpiA(LPCSTR arg1, LPCSTR arg2)
|
|---|
| 443 | {
|
|---|
| 444 | dprintf(("KERNEL32: lstrcmpiA(%s,%s)\n",
|
|---|
| 445 | arg1,
|
|---|
| 446 | arg2));
|
|---|
| 447 |
|
|---|
| 448 | return O32_lstrcmpi(arg1, arg2);
|
|---|
| 449 | }
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 | /*****************************************************************************
|
|---|
| 453 | * Name :
|
|---|
| 454 | * Purpose :
|
|---|
| 455 | * Parameters:
|
|---|
| 456 | * Variables :
|
|---|
| 457 | * Result :
|
|---|
| 458 | * Remark :
|
|---|
| 459 | * Status :
|
|---|
| 460 | *
|
|---|
| 461 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 462 | *****************************************************************************/
|
|---|
| 463 |
|
|---|
| 464 | int WIN32API lstrcmpiW(LPCWSTR arg1, LPCWSTR arg2)
|
|---|
| 465 | {
|
|---|
| 466 | char *astr1, *astr2;
|
|---|
| 467 | int rc;
|
|---|
| 468 |
|
|---|
| 469 | dprintf(("KERNEL32: lstrcmpiW(%08xh,%08xh)\n",
|
|---|
| 470 | arg1,
|
|---|
| 471 | arg2));
|
|---|
| 472 |
|
|---|
| 473 | // NOTE: This function has no equivalent in uunidef.h
|
|---|
| 474 | astr1 = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 475 | astr2 = UnicodeToAsciiString((LPWSTR)arg2);
|
|---|
| 476 | rc = O32_lstrcmpi(astr1, astr2);
|
|---|
| 477 | FreeAsciiString(astr2);
|
|---|
| 478 | FreeAsciiString(astr1);
|
|---|
| 479 | return(rc);
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 |
|
|---|
| 483 | /*****************************************************************************
|
|---|
| 484 | * Name :
|
|---|
| 485 | * Purpose :
|
|---|
| 486 | * Parameters:
|
|---|
| 487 | * Variables :
|
|---|
| 488 | * Result :
|
|---|
| 489 | * Remark :
|
|---|
| 490 | * Status :
|
|---|
| 491 | *
|
|---|
| 492 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 493 | *****************************************************************************/
|
|---|
| 494 |
|
|---|
| 495 | // unilen: length of astring buffer (including 0 terminator)
|
|---|
| 496 | // returns string length
|
|---|
| 497 |
|
|---|
| 498 | int WIN32API lstrcpynWtoA(LPSTR astring,
|
|---|
| 499 | LPWSTR ustring,
|
|---|
| 500 | int unilen)
|
|---|
| 501 | {
|
|---|
| 502 | int i;
|
|---|
| 503 | int rc;
|
|---|
| 504 | size_t uni_chars_left;
|
|---|
| 505 | size_t out_bytes_left;
|
|---|
| 506 | size_t num_subs;
|
|---|
| 507 | UniChar* in_buf;
|
|---|
| 508 | char* out_buf;
|
|---|
| 509 |
|
|---|
| 510 | if (ustring == NULL)
|
|---|
| 511 | {
|
|---|
| 512 | if (astring != NULL && unilen > 0)
|
|---|
| 513 | astring[0] = 0;
|
|---|
| 514 | return 0;
|
|---|
| 515 | }
|
|---|
| 516 |
|
|---|
| 517 | if (astring == NULL || unilen <= 0)
|
|---|
| 518 | return 0;
|
|---|
| 519 |
|
|---|
| 520 | if (getUconvObject())
|
|---|
| 521 | {
|
|---|
| 522 | if (unilen == 1)
|
|---|
| 523 | {
|
|---|
| 524 | astring[0] = 0;
|
|---|
| 525 | return 0; //no data
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | uni_chars_left = unilen-1; //elements
|
|---|
| 529 | out_bytes_left = uni_chars_left; //size in bytes == elements
|
|---|
| 530 | in_buf = (UniChar*)ustring;
|
|---|
| 531 | out_buf = astring;
|
|---|
| 532 | rc = UniUconvFromUcs(uconv_object,
|
|---|
| 533 | &in_buf, &uni_chars_left,
|
|---|
| 534 | (void**)&out_buf, &out_bytes_left,
|
|---|
| 535 | &num_subs);
|
|---|
| 536 |
|
|---|
| 537 | unilen -= 1+out_bytes_left; //end + left bytes
|
|---|
| 538 | astring[unilen] = 0; //terminate
|
|---|
| 539 |
|
|---|
| 540 | return unilen;
|
|---|
| 541 |
|
|---|
| 542 | }
|
|---|
| 543 | else
|
|---|
| 544 | {
|
|---|
| 545 | /* idiots unicode conversion :) */
|
|---|
| 546 | for (i = 0; i < unilen-1; i++)
|
|---|
| 547 | {
|
|---|
| 548 | astring[i] = (ustring[i] > 255) ? (char)20 : (char)ustring[i]; //CB: handle invalid characters as space
|
|---|
| 549 | if (ustring[i] == 0) return i; //asta la vista, baby
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 552 | astring[unilen-1] = 0; // @@@PH: 1999/06/09 fix - always terminate string
|
|---|
| 553 |
|
|---|
| 554 | return(unilen-1);
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 |
|
|---|
| 559 | /*****************************************************************************
|
|---|
| 560 | * Name :
|
|---|
| 561 | * Purpose :
|
|---|
| 562 | * Parameters:
|
|---|
| 563 | * Variables :
|
|---|
| 564 | * Result :
|
|---|
| 565 | * Remark :
|
|---|
| 566 | * Status :
|
|---|
| 567 | *
|
|---|
| 568 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 569 | *****************************************************************************/
|
|---|
| 570 |
|
|---|
| 571 | // asciilen: max length of unicode buffer (including end 0)
|
|---|
| 572 |
|
|---|
| 573 | int WIN32API lstrcpynAtoW(LPWSTR unicode,
|
|---|
| 574 | LPSTR ascii,
|
|---|
| 575 | int asciilen)
|
|---|
| 576 | {
|
|---|
| 577 | int rc;
|
|---|
| 578 | int i;
|
|---|
| 579 | size_t uni_chars_left;
|
|---|
| 580 | size_t in_bytes_left;
|
|---|
| 581 | size_t num_subs;
|
|---|
| 582 | UniChar* out_buf;
|
|---|
| 583 | char* in_buf;
|
|---|
| 584 |
|
|---|
| 585 | dprintf(("KERNEL32: HeapString: lstrcpynAtoW(%s,%08xh)\n",
|
|---|
| 586 | ascii,
|
|---|
| 587 | unicode));
|
|---|
| 588 |
|
|---|
| 589 | //CB: no input, set at least terminator
|
|---|
| 590 | if (ascii == NULL)
|
|---|
| 591 | {
|
|---|
| 592 | if (unicode != NULL && asciilen > 0) unicode[0] = 0;
|
|---|
| 593 | return 0;
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | if (unicode == NULL || asciilen <= 0)
|
|---|
| 597 | return 0; //nothing to do
|
|---|
| 598 |
|
|---|
| 599 | if (getUconvObject())
|
|---|
| 600 | {
|
|---|
| 601 | if (asciilen == 1)
|
|---|
| 602 | {
|
|---|
| 603 | unicode[0] = 0;
|
|---|
| 604 | return 0;
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 | in_buf = ascii;
|
|---|
| 608 | in_bytes_left = asciilen-1; //buffer size in bytes
|
|---|
| 609 | out_buf = (UniChar*)unicode;
|
|---|
| 610 |
|
|---|
| 611 | uni_chars_left = in_bytes_left; //elements
|
|---|
| 612 |
|
|---|
| 613 | rc = UniUconvToUcs( uconv_object,
|
|---|
| 614 | (void**)&in_buf, &in_bytes_left,
|
|---|
| 615 | &out_buf, &uni_chars_left,
|
|---|
| 616 | &num_subs );
|
|---|
| 617 |
|
|---|
| 618 | unicode[asciilen-1-in_bytes_left] = 0;
|
|---|
| 619 |
|
|---|
| 620 | //if (rc != ULS_SUCCESS && in_bytes_left > 0) //CB: never the case during my tests
|
|---|
| 621 | // dprintf(("KERNEL32: AsciiToUnicode failed, %d bytes left!\n",in_bytes_left));
|
|---|
| 622 | return asciilen - 1;
|
|---|
| 623 | }
|
|---|
| 624 | else
|
|---|
| 625 | { //poor man's conversion
|
|---|
| 626 |
|
|---|
| 627 | for(i = 0;i < asciilen-1;i++)
|
|---|
| 628 | {
|
|---|
| 629 | unicode[i] = ascii[i];
|
|---|
| 630 | if (ascii[i] == 0)
|
|---|
| 631 | return i-1; //work done
|
|---|
| 632 | }
|
|---|
| 633 |
|
|---|
| 634 | unicode[asciilen-1] = 0;
|
|---|
| 635 | return asciilen-1;
|
|---|
| 636 | }
|
|---|
| 637 | }
|
|---|
| 638 |
|
|---|
| 639 |
|
|---|
| 640 | /*****************************************************************************
|
|---|
| 641 | * Name :
|
|---|
| 642 | * Purpose : Converts unicode string to ascii string
|
|---|
| 643 | * Parameters:
|
|---|
| 644 | * Variables :
|
|---|
| 645 | * Result : returns length of ascii string
|
|---|
| 646 | * Remark :
|
|---|
| 647 | * Status :
|
|---|
| 648 | *
|
|---|
| 649 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 650 | *****************************************************************************/
|
|---|
| 651 |
|
|---|
| 652 | LPSTR WIN32API lstrcpyWtoA(LPSTR ascii, LPWSTR unicode)
|
|---|
| 653 | {
|
|---|
| 654 | if (unicode == NULL)
|
|---|
| 655 | {
|
|---|
| 656 | if (unicode != NULL) unicode[0] = 0; //CB: set at least end
|
|---|
| 657 | return NULL;
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | if (unicode == NULL)
|
|---|
| 661 | return NULL; /* garbage in, garbage out ! */
|
|---|
| 662 |
|
|---|
| 663 | /* forward to function with len parameter */
|
|---|
| 664 | lstrcpynWtoA(ascii,
|
|---|
| 665 | unicode,
|
|---|
| 666 | UniStrlen((UniChar*)unicode)+1); //end included
|
|---|
| 667 |
|
|---|
| 668 | return ascii;
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 |
|
|---|
| 672 | /*****************************************************************************
|
|---|
| 673 | * Name :
|
|---|
| 674 | * Purpose : Copies the full string from ascii to unicode
|
|---|
| 675 | * Parameters:
|
|---|
| 676 | * Variables :
|
|---|
| 677 | * Result :
|
|---|
| 678 | * Remark :
|
|---|
| 679 | * Status :
|
|---|
| 680 | *
|
|---|
| 681 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 682 | *****************************************************************************/
|
|---|
| 683 |
|
|---|
| 684 | LPWSTR WIN32API lstrcpyAtoW(LPWSTR unicode, LPSTR ascii)
|
|---|
| 685 | {
|
|---|
| 686 | /* achimha for security, strlen might trap if garbage in */
|
|---|
| 687 | /* @@@PH 98/06/07 */
|
|---|
| 688 | if (ascii == NULL)
|
|---|
| 689 | {
|
|---|
| 690 | if (unicode != NULL) unicode[0] = 0; //CB: set at least end
|
|---|
| 691 | return NULL;
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | if (unicode == NULL)
|
|---|
| 695 | return NULL; /* garbage in, garbage out ! */
|
|---|
| 696 |
|
|---|
| 697 | /* forward to call with length parameter */
|
|---|
| 698 | lstrcpynAtoW(unicode, ascii, strlen(ascii)+1); //end included
|
|---|
| 699 | return (unicode);
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 |
|
|---|
| 704 |
|
|---|
| 705 | /*****************************************************************************
|
|---|
| 706 | * Name :
|
|---|
| 707 | * Purpose :
|
|---|
| 708 | * Parameters:
|
|---|
| 709 | * Variables :
|
|---|
| 710 | * Result :
|
|---|
| 711 | * Remark :
|
|---|
| 712 | * Status :
|
|---|
| 713 | *
|
|---|
| 714 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 715 | *****************************************************************************/
|
|---|
| 716 |
|
|---|
| 717 | LPVOID WIN32API HEAP_xalloc( HANDLE heap, DWORD flags, DWORD size )
|
|---|
| 718 | {
|
|---|
| 719 | LPVOID p = HeapAlloc( heap, flags, size );
|
|---|
| 720 | if (!p)
|
|---|
| 721 | {
|
|---|
| 722 | dprintf(("KERNEL32: HEAP_xalloc(%08xh,%08xh,%08xh) out of memory.\n",
|
|---|
| 723 | heap,
|
|---|
| 724 | flags,
|
|---|
| 725 | size));
|
|---|
| 726 | }
|
|---|
| 727 | return p;
|
|---|
| 728 | }
|
|---|
| 729 |
|
|---|
| 730 |
|
|---|
| 731 | /*****************************************************************************
|
|---|
| 732 | * Name :
|
|---|
| 733 | * Purpose :
|
|---|
| 734 | * Parameters:
|
|---|
| 735 | * Variables :
|
|---|
| 736 | * Result :
|
|---|
| 737 | * Remark :
|
|---|
| 738 | * Status :
|
|---|
| 739 | *
|
|---|
| 740 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 741 | *****************************************************************************/
|
|---|
| 742 |
|
|---|
| 743 | LPVOID WIN32API HEAP_xrealloc( HANDLE heap, DWORD flags, LPVOID lpMem, DWORD size )
|
|---|
| 744 | {
|
|---|
| 745 | LPVOID p = HeapReAlloc( heap, flags, lpMem, size );
|
|---|
| 746 | if (!p)
|
|---|
| 747 | {
|
|---|
| 748 | dprintf(("KERNEL32: HEAP_xrealloc(%08xh,%08xh,%08xh,%08xh) out of memory.\n",
|
|---|
| 749 | heap,
|
|---|
| 750 | flags,
|
|---|
| 751 | lpMem,
|
|---|
| 752 | size));
|
|---|
| 753 | }
|
|---|
| 754 | return p;
|
|---|
| 755 | }
|
|---|
| 756 |
|
|---|
| 757 |
|
|---|
| 758 | /*****************************************************************************
|
|---|
| 759 | * Name :
|
|---|
| 760 | * Purpose :
|
|---|
| 761 | * Parameters:
|
|---|
| 762 | * Variables :
|
|---|
| 763 | * Result :
|
|---|
| 764 | * Remark :
|
|---|
| 765 | * Status :
|
|---|
| 766 | *
|
|---|
| 767 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 768 | *****************************************************************************/
|
|---|
| 769 |
|
|---|
| 770 | LPVOID WIN32API HEAP_malloc(DWORD size )
|
|---|
| 771 | {
|
|---|
| 772 | LPVOID p = HeapAlloc( GetProcessHeap(), 0, size );
|
|---|
| 773 | if (!p)
|
|---|
| 774 | {
|
|---|
| 775 | dprintf(("KERNEL32: HEAP_malloc(%08xh) out of memory.\n",
|
|---|
| 776 | size));
|
|---|
| 777 | }
|
|---|
| 778 | return p;
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 |
|
|---|
| 782 | /*****************************************************************************
|
|---|
| 783 | * Name :
|
|---|
| 784 | * Purpose :
|
|---|
| 785 | * Parameters:
|
|---|
| 786 | * Variables :
|
|---|
| 787 | * Result :
|
|---|
| 788 | * Remark :
|
|---|
| 789 | * Status :
|
|---|
| 790 | *
|
|---|
| 791 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 792 | *****************************************************************************/
|
|---|
| 793 |
|
|---|
| 794 | LPVOID WIN32API HEAP_realloc(LPVOID lpMem, DWORD size )
|
|---|
| 795 | {
|
|---|
| 796 | LPVOID p = HeapReAlloc( GetProcessHeap(), 0, lpMem, size );
|
|---|
| 797 | if (!p)
|
|---|
| 798 | {
|
|---|
| 799 | dprintf(("KERNEL32: HEAP_realloc(%08xh,%08xh) out of memory.\n",
|
|---|
| 800 | lpMem,
|
|---|
| 801 | size));
|
|---|
| 802 | }
|
|---|
| 803 | return p;
|
|---|
| 804 | }
|
|---|
| 805 |
|
|---|
| 806 |
|
|---|
| 807 | /*****************************************************************************
|
|---|
| 808 | * Name :
|
|---|
| 809 | * Purpose :
|
|---|
| 810 | * Parameters:
|
|---|
| 811 | * Variables :
|
|---|
| 812 | * Result :
|
|---|
| 813 | * Remark :
|
|---|
| 814 | * Status :
|
|---|
| 815 | *
|
|---|
| 816 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 817 | *****************************************************************************/
|
|---|
| 818 |
|
|---|
| 819 | VOID WIN32API HEAP_free(LPVOID lpMem)
|
|---|
| 820 | {
|
|---|
| 821 | dprintf(("KERNEL32: HEAP_free(%08xh)\n",
|
|---|
| 822 | lpMem));
|
|---|
| 823 |
|
|---|
| 824 | HeapFree( GetProcessHeap(), 0, lpMem);
|
|---|
| 825 | }
|
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 | /*****************************************************************************
|
|---|
| 829 | * Name :
|
|---|
| 830 | * Purpose :
|
|---|
| 831 | * Parameters:
|
|---|
| 832 | * Variables :
|
|---|
| 833 | * Result :
|
|---|
| 834 | * Remark :
|
|---|
| 835 | * Status :
|
|---|
| 836 | *
|
|---|
| 837 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 838 | *****************************************************************************/
|
|---|
| 839 |
|
|---|
| 840 | LPSTR WIN32API HEAP_strdupA( HANDLE heap, DWORD flags, LPCSTR str )
|
|---|
| 841 | {
|
|---|
| 842 | LPSTR p = (LPSTR)HEAP_xalloc( heap, flags, strlen(str) + 1 );
|
|---|
| 843 | strcpy( p, str );
|
|---|
| 844 | return p;
|
|---|
| 845 | }
|
|---|
| 846 |
|
|---|
| 847 |
|
|---|
| 848 | /*****************************************************************************
|
|---|
| 849 | * Name :
|
|---|
| 850 | * Purpose :
|
|---|
| 851 | * Parameters:
|
|---|
| 852 | * Variables :
|
|---|
| 853 | * Result :
|
|---|
| 854 | * Remark :
|
|---|
| 855 | * Status :
|
|---|
| 856 | *
|
|---|
| 857 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 858 | *****************************************************************************/
|
|---|
| 859 |
|
|---|
| 860 | LPWSTR WIN32API HEAP_strdupW( HANDLE heap, DWORD flags, LPCWSTR str )
|
|---|
| 861 | {
|
|---|
| 862 | INT len = lstrlenW(str) + 1;
|
|---|
| 863 | LPWSTR p = (LPWSTR)HEAP_xalloc( heap, flags, len * sizeof(WCHAR) );
|
|---|
| 864 | lstrcpyW( p, str );
|
|---|
| 865 | return p;
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 |
|
|---|
| 869 | /*****************************************************************************
|
|---|
| 870 | * Name :
|
|---|
| 871 | * Purpose :
|
|---|
| 872 | * Parameters:
|
|---|
| 873 | * Variables :
|
|---|
| 874 | * Result :
|
|---|
| 875 | * Remark :
|
|---|
| 876 | * Status :
|
|---|
| 877 | *
|
|---|
| 878 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 879 | *****************************************************************************/
|
|---|
| 880 |
|
|---|
| 881 | LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str )
|
|---|
| 882 | {
|
|---|
| 883 | LPWSTR ret;
|
|---|
| 884 |
|
|---|
| 885 | if (!str) return NULL;
|
|---|
| 886 | ret = (LPWSTR)HEAP_xalloc( heap, flags, (strlen(str)+1) * sizeof(WCHAR) );
|
|---|
| 887 | lstrcpyAtoW( ret, (LPSTR)str );
|
|---|
| 888 | return ret;
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 |
|
|---|
| 892 | /*****************************************************************************
|
|---|
| 893 | * Name :
|
|---|
| 894 | * Purpose :
|
|---|
| 895 | * Parameters:
|
|---|
| 896 | * Variables :
|
|---|
| 897 | * Result :
|
|---|
| 898 | * Remark :
|
|---|
| 899 | * Status :
|
|---|
| 900 | *
|
|---|
| 901 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 902 | *****************************************************************************/
|
|---|
| 903 |
|
|---|
| 904 | LPSTR WIN32API HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str )
|
|---|
| 905 | {
|
|---|
| 906 | LPSTR ret;
|
|---|
| 907 |
|
|---|
| 908 | if (!str) return NULL;
|
|---|
| 909 | ret = (LPSTR)HEAP_xalloc( heap, flags, lstrlenW(str) + 1 );
|
|---|
| 910 | lstrcpyWtoA( ret, (LPWSTR)str );
|
|---|
| 911 | return ret;
|
|---|
| 912 | }
|
|---|
| 913 |
|
|---|
| 914 |
|
|---|
| 915 | /*****************************************************************************
|
|---|
| 916 | * Name : WideCharToLocal
|
|---|
| 917 | * Purpose : similar lstrcpyWtoA, should handle codepages properly
|
|---|
| 918 | * Parameters:
|
|---|
| 919 | * Variables :
|
|---|
| 920 | * Result : strlen of the destination string
|
|---|
| 921 | * Remark :
|
|---|
| 922 | * Status :
|
|---|
| 923 | *
|
|---|
| 924 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 925 | *****************************************************************************/
|
|---|
| 926 |
|
|---|
| 927 | INT WIN32API WideCharToLocal(LPSTR pLocal, LPWSTR pWide, INT dwChars)
|
|---|
| 928 | {
|
|---|
| 929 | dprintf(("KERNEL32: WideCharToLocal(%08xh,%08xh,%08xh)\n",
|
|---|
| 930 | pLocal,
|
|---|
| 931 | pWide,
|
|---|
| 932 | dwChars));
|
|---|
| 933 |
|
|---|
| 934 | *pLocal = 0;
|
|---|
| 935 | WideCharToMultiByte(CP_ACP,
|
|---|
| 936 | 0,
|
|---|
| 937 | pWide,
|
|---|
| 938 | -1,
|
|---|
| 939 | pLocal,
|
|---|
| 940 | dwChars,
|
|---|
| 941 | NULL,
|
|---|
| 942 | NULL);
|
|---|
| 943 |
|
|---|
| 944 | return strlen(pLocal);
|
|---|
| 945 | }
|
|---|
| 946 |
|
|---|
| 947 |
|
|---|
| 948 | /*****************************************************************************
|
|---|
| 949 | * Name : LocalToWideChar
|
|---|
| 950 | * Purpose : similar lstrcpyAtoW, should handle codepages properly
|
|---|
| 951 | * Parameters:
|
|---|
| 952 | * Variables :
|
|---|
| 953 | * Result : strlen of the destination string
|
|---|
| 954 | * Remark :
|
|---|
| 955 | * Status :
|
|---|
| 956 | *
|
|---|
| 957 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 958 | *****************************************************************************/
|
|---|
| 959 |
|
|---|
| 960 | INT WIN32API LocalToWideChar(LPWSTR pWide, LPSTR pLocal, INT dwChars)
|
|---|
| 961 | {
|
|---|
| 962 | *pWide = 0;
|
|---|
| 963 |
|
|---|
| 964 | dprintf(("KERNEL32: LocalToWideChar(%08xh,%08xh,%08xh)\n",
|
|---|
| 965 | pLocal,
|
|---|
| 966 | pWide,
|
|---|
| 967 | dwChars));
|
|---|
| 968 |
|
|---|
| 969 | MultiByteToWideChar(CP_ACP,
|
|---|
| 970 | 0,
|
|---|
| 971 | pLocal,
|
|---|
| 972 | -1,
|
|---|
| 973 | pWide,
|
|---|
| 974 | dwChars);
|
|---|
| 975 |
|
|---|
| 976 | return lstrlenW(pWide);
|
|---|
| 977 | }
|
|---|
| 978 |
|
|---|
| 979 |
|
|---|
| 980 |
|
|---|
| 981 |
|
|---|
| 982 |
|
|---|
| 983 |
|
|---|
| 984 | #if 0
|
|---|
| 985 |
|
|---|
| 986 |
|
|---|
| 987 | /*****************************************************************************
|
|---|
| 988 | * Name :
|
|---|
| 989 | * Purpose :
|
|---|
| 990 | * Parameters:
|
|---|
| 991 | * Variables :
|
|---|
| 992 | * Result :
|
|---|
| 993 | * Remark :
|
|---|
| 994 | * Status :
|
|---|
| 995 | *
|
|---|
| 996 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 997 | *****************************************************************************/
|
|---|
| 998 |
|
|---|
| 999 | // Converts unicode string to ascii string
|
|---|
| 1000 | // returns pointer to ascii string
|
|---|
| 1001 | char * WIN32API UnicodeToAsciiString(WCHAR *ustring)
|
|---|
| 1002 | {
|
|---|
| 1003 | char *astring;
|
|---|
| 1004 |
|
|---|
| 1005 | if(ustring == NULL) return(NULL);
|
|---|
| 1006 |
|
|---|
| 1007 | astring = (char *)malloc( 1 + UniStrlen((UniChar*)ustring) );
|
|---|
| 1008 | UnicodeToAscii( ustring, astring );
|
|---|
| 1009 | return(astring);
|
|---|
| 1010 | }
|
|---|
| 1011 |
|
|---|
| 1012 |
|
|---|
| 1013 | /*****************************************************************************
|
|---|
| 1014 | * Name :
|
|---|
| 1015 | * Purpose :
|
|---|
| 1016 | * Parameters:
|
|---|
| 1017 | * Variables :
|
|---|
| 1018 | * Result :
|
|---|
| 1019 | * Remark :
|
|---|
| 1020 | * Status :
|
|---|
| 1021 | *
|
|---|
| 1022 | * Author : Patrick Haller [Thu, 1999/08/05 20:46]
|
|---|
| 1023 | *****************************************************************************/
|
|---|
| 1024 |
|
|---|
| 1025 | // Converts ascii string to unicode string
|
|---|
| 1026 | // returns pointer to unicode string
|
|---|
| 1027 | WCHAR * WIN32API AsciiToUnicodeString(char *astring)
|
|---|
| 1028 | {
|
|---|
| 1029 | WCHAR *ustring;
|
|---|
| 1030 |
|
|---|
| 1031 | if(astring == NULL)
|
|---|
| 1032 | return(NULL);
|
|---|
| 1033 |
|
|---|
| 1034 | ustring = (WCHAR *)malloc( 1 + strlen(astring) << 1 );
|
|---|
| 1035 | AsciiToUnicode( astring, ustring );
|
|---|
| 1036 | return(ustring);
|
|---|
| 1037 | }
|
|---|
| 1038 |
|
|---|
| 1039 | #endif
|
|---|
| 1040 |
|
|---|
| 1041 |
|
|---|
| 1042 |
|
|---|