Changeset 93059 in vbox
- Timestamp:
- Dec 22, 2021 2:29:22 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/utf8-win.cpp
r82968 r93059 50 50 Assert(ppszString); 51 51 Assert(pszString); 52 *ppszString = NULL; 52 53 53 54 /* 54 * Check for zero length input string. 55 * If the ANSI codepage (CP_ACP) is UTF-8, no translation is needed. 56 * Same goes for empty strings. 55 57 */ 56 if (cchString < 1 || !*pszString) 58 if ( cchString == 0 59 || *pszString == '\0') 60 return RTStrDupNExTag(ppszString, pszString, 0, pszTag); 61 if (GetACP() == CP_UTF8) 57 62 { 58 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag); 59 if (*ppszString) 60 return VINF_SUCCESS; 61 return VERR_NO_TMP_MEMORY; 63 int rc = RTStrValidateEncodingEx(pszString, cchString, 0); 64 AssertRCReturn(rc, rc); 65 return RTStrDupNExTag(ppszString, pszString, cchString, pszTag); 62 66 } 63 64 *ppszString = NULL;65 67 66 68 /* … … 122 124 *ppszString = NULL; 123 125 126 /* 127 * If the ANSI codepage (CP_ACP) is UTF-8, no translation is needed. 128 * Same goes for empty strings. 129 */ 130 if (*pszString == '\0') 131 return RTStrDupExTag(ppszString, pszString, pszTag); 132 if (GetACP() == CP_UTF8) 133 { 134 int rc = RTStrValidateEncoding(pszString); 135 AssertRCReturn(rc, rc); 136 return RTStrDupExTag(ppszString, pszString, pszTag); 137 } 138 124 139 /** @todo is there a quicker way? Currently: ACP -> UTF-16 -> UTF-8 */ 125 126 size_t cch = strlen(pszString);127 if (cch <= 0)128 {129 /* zero length string passed. */130 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);131 if (*ppszString)132 return VINF_SUCCESS;133 return VERR_NO_TMP_MEMORY;134 }135 140 136 141 /*
Note:
See TracChangeset
for help on using the changeset viewer.