Changeset 10176 for trunk/src/kernel32/heapstring.cpp
- Timestamp:
- Jul 16, 2003, 8:07:01 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/heapstring.cpp
r9975 r10176 1 /* $Id: heapstring.cpp,v 1.5 2 2003-04-02 12:58:29sandervl Exp $ */1 /* $Id: heapstring.cpp,v 1.53 2003-07-16 18:07:01 sandervl Exp $ */ 2 2 /* 3 3 * Project Odin Software License can be found in LICENSE.TXT … … 410 410 */ 411 411 if (!dst || !src) { 412 413 412 SetLastError(ERROR_INVALID_PARAMETER); 413 return 0; 414 414 } 415 415 while ((n-- > 1) && *src) *p++ = *src++; … … 462 462 { 463 463 if (!str1 || !str2) { 464 464 465 465 SetLastError(ERROR_INVALID_PARAMETER); 466 466 return 0; … … 495 495 //lstrcpynWtoA and lstrcpynAtoW must zero-terminate the string 496 496 //because Wine code depends on this behaviour (i.e. comdlg32) 497 int WIN32API lstrcpynAtoW(LPWSTR unicode, LPCSTR ascii, int asciilen)497 int WIN32API lstrcpynAtoW(LPWSTR unicode, LPCSTR ascii, int unilen) 498 498 { 499 499 int ret; 500 500 501 ret = MultiByteToWideChar(CP_ACP, 0, ascii, -1, unicode, asciilen);501 ret = MultiByteToWideChar(CP_ACP, 0, ascii, -1, unicode, unilen ); 502 502 if(ret == 0) { 503 503 SetLastError(ERROR_SUCCESS); //MultiByteToWideChar sets it to ERROR_INSUFFICIENT_BUFFER 504 ret = asciilen;504 ret = unilen; 505 505 } 506 506 … … 508 508 //string size to apis that use this function (i.e. GetMenuStringW (Notes)) 509 509 //-> overwrites stack 510 if(ret == asciilen) {511 unicode[ asciilen-1] = 0;510 if(ret == unilen) { 511 unicode[unilen-1] = 0; 512 512 } 513 513 else unicode[ret] = 0; 514 514 return ret; 515 516 517 515 } 518 516 … … 547 545 lstrcpynWtoA(ascii, 548 546 unicode, 549 lstrlenW(unicode)+1); //end included547 WideCharToMultiByte( CP_ACP, 0, unicode, -1, 0, 0, 0, 0 )); //end included 550 548 551 549 return ascii; … … 582 580 583 581 /* forward to call with length parameter */ 584 lstrcpynAtoW(unicode, ascii, strlen(ascii)+1); //end included582 lstrcpynAtoW(unicode, ascii, MultiByteToWideChar( CP_ACP, 0, ascii, -1, 0, 0 )); //end included 585 583 return (unicode); 586 584 } 587 585 588 589 586 /***************************************************************************** 587 * NAME 588 * lstrlenWtoA 589 * 590 * PURPOSE 591 * calculate the length of string when unicode string was converted to 592 * ansi string. 593 * 594 * PARAMETERS 595 * ustring - unicode string 596 * ulen - length of ustring 597 * 598 * RESULT 599 * Success 600 * if ulen < 0, length of null-terminated unicode string NOT including 601 * null-terminator. 602 * otherwise, length of string when first ulen characters of ustring 603 * converted to ansi string. 604 * 605 * Failure 606 * return 0. 607 * 608 * REMARK 609 * this function is not Win32 API but helper for convenient. 610 * 611 * AUTHOR : KO Myung-Hun 612 *****************************************************************************/ 613 614 int WIN32API lstrlenWtoA( LPCWSTR ustring, int ulen ) 615 { 616 int ret; 617 618 if( ulen < 0 ) 619 ulen = lstrlenW( ustring ); 620 621 ret = WideCharToMultiByte( CP_ACP, 0, ustring, ulen, 0, 0, 0, 0 ); 622 if(ret == 0) { 623 SetLastError(ERROR_SUCCESS); //WideCharToMultiByte sets it to ERROR_INSUFFICIENT_BUFFER 624 return 0; 625 } 626 627 return ret; 628 } 629 630 /***************************************************************************** 631 * NAME 632 * lstrlenAtoW 633 * 634 * PURPOSE 635 * return the length of string when ansi string was converted to 636 * unicode string. 637 * 638 * PARAMETERS 639 * astring - ansi string 640 * alen - length of astring 641 * 642 * RESULT 643 * Success 644 * if alen < 0, length of null-terminated ansi string NOT including 645 * null-terminator. 646 * otherwise, length of string when first alen characters of astring 647 * converted to unicode string. 648 * 649 * Failure 650 * return 0. 651 * 652 * REMARK 653 * this function is not Win32 API but helper for convenient. 654 * 655 * AUTHOR : KO Myung-Hun 656 *****************************************************************************/ 657 658 int WIN32API lstrlenAtoW( LPCSTR astring, int alen ) 659 { 660 int ret; 661 662 if( alen < 0 ) 663 alen = strlen( astring ); 664 665 ret = MultiByteToWideChar( CP_ACP, 0, astring, alen, 0, 0 ); 666 if(ret == 0) { 667 SetLastError(ERROR_SUCCESS); //MultiByteToWideChar sets it to ERROR_INSUFFICIENT_BUFFER 668 return 0; 669 } 670 671 return ret; 672 } 590 673 591 674 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.