Changeset 38658 in vbox for trunk/src/VBox/Runtime/common/string/strformat.cpp
- Timestamp:
- Sep 6, 2011 2:22:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformat.cpp
r33540 r38658 483 483 } 484 484 485 #ifndef IN_RING3 486 case 'S': /* Unicode string as current code page -> Unicode as UTF-8 in GC/R0. */ 487 chArgSize = 'l'; /** @todo this is nonsensical, isn't it? */ 488 /* fall thru */ 489 #endif 490 case 's': /* Unicode string as utf8 */ 485 case 'S': /* Legacy, conversion done by streams now. */ 486 case 's': 491 487 { 492 488 if (chArgSize == 'l') … … 508 504 while (cchStr-- > 0) 509 505 { 510 #if def IN_RING3506 #ifndef IN_RC 511 507 RTUNICP Cp; 512 508 RTUtf16GetCpEx(&pwszStr, &Cp); … … 541 537 while (cchStr-- > 0) 542 538 { 543 #if def IN_RING3539 #ifndef IN_RC 544 540 char szUtf8[8]; /* Cp=0x7fffffff -> 6 bytes. */ 545 541 char *pszEnd = RTStrPutCp(szUtf8, *puszStr++); … … 572 568 break; 573 569 } 574 575 #ifdef IN_RING3576 case 'S': /* Unicode string as current code page. */577 {578 if (chArgSize == 'l')579 {580 /* UTF-16 */581 int cchStr;582 PCRTUTF16 pwsz2Str = va_arg(args, PRTUTF16);583 if (!VALID_PTR(pwsz2Str))584 {585 static RTUTF16 s_wsz2Null[] = {'<', 'N', 'U', 'L', 'L', '>', '\0' };586 pwsz2Str = s_wsz2Null;587 }588 589 cchStr = _strnlenUtf16(pwsz2Str, (unsigned)cchPrecision);590 if (!(fFlags & RTSTR_F_LEFT))591 while (--cchWidth >= cchStr)592 cch += pfnOutput(pvArgOutput, " ", 1);593 594 if (cchStr)595 {596 /* allocate temporary buffer. */597 PRTUTF16 pwsz2Tmp = (PRTUTF16)RTMemTmpAlloc((cchStr + 1) * sizeof(RTUTF16));598 memcpy(pwsz2Tmp, pwsz2Str, cchStr * sizeof(RTUTF16));599 pwsz2Tmp[cchStr] = '\0';600 601 char *pszUtf8;602 int rc = RTUtf16ToUtf8(pwsz2Tmp, &pszUtf8);603 if (RT_SUCCESS(rc))604 {605 char *pszCurCp;606 rc = RTStrUtf8ToCurrentCP(&pszCurCp, pszUtf8);607 if (RT_SUCCESS(rc))608 {609 cch += pfnOutput(pvArgOutput, pszCurCp, strlen(pszCurCp));610 RTStrFree(pszCurCp);611 }612 RTStrFree(pszUtf8);613 }614 if (RT_FAILURE(rc))615 while (cchStr-- > 0)616 cch += pfnOutput(pvArgOutput, "\x7f", 1);617 RTMemTmpFree(pwsz2Tmp);618 }619 620 while (--cchWidth >= cchStr)621 cch += pfnOutput(pvArgOutput, " ", 1);622 }623 else if (chArgSize == 'L')624 {625 /* UCS-32 */626 AssertMsgFailed(("Not implemented yet\n"));627 }628 else629 {630 /* UTF-8 */631 int cchStr;632 const char *pszStr = va_arg(args, char *);633 634 if (!VALID_PTR(pszStr))635 pszStr = "<NULL>";636 cchStr = _strnlen(pszStr, (unsigned)cchPrecision);637 if (!(fFlags & RTSTR_F_LEFT))638 while (--cchWidth >= cchStr)639 cch += pfnOutput(pvArgOutput, " ", 1);640 641 if (cchStr)642 {643 /* allocate temporary buffer. */644 char *pszTmp = (char *)RTMemTmpAlloc(cchStr + 1);645 memcpy(pszTmp, pszStr, cchStr);646 pszTmp[cchStr] = '\0';647 648 char *pszCurCp;649 int rc = RTStrUtf8ToCurrentCP(&pszCurCp, pszTmp);650 if (RT_SUCCESS(rc))651 {652 cch += pfnOutput(pvArgOutput, pszCurCp, strlen(pszCurCp));653 RTStrFree(pszCurCp);654 }655 else656 while (cchStr-- > 0)657 cch += pfnOutput(pvArgOutput, "\x7f", 1);658 RTMemTmpFree(pszTmp);659 }660 661 while (--cchWidth >= cchStr)662 cch += pfnOutput(pvArgOutput, " ", 1);663 }664 break;665 }666 #endif667 668 570 669 571 /*-----------------*/
Note:
See TracChangeset
for help on using the changeset viewer.