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