Changeset 40071 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Feb 10, 2012 9:35:27 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76205
- Location:
- trunk/src/VBox/Runtime/common/string
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/utf-16.cpp
r31157 r40071 250 250 251 251 252 ssize_t RTUtf16PurgeComplementSet(PRTUTF16 pwsz, PCRTUNICP puszValidSet, char chReplacement) 253 { 254 size_t cReplacements = 0; 255 AssertReturn(chReplacement && (unsigned)chReplacement < 128, -1); 256 /* Validate the encoding. */ 257 if (RT_FAILURE(RTUtf16CalcUtf8LenEx(pwsz, RTSTR_MAX, NULL))) 258 return -1; 259 for (;;) 260 { 261 RTUNICP Cp; 262 PCRTUNICP pCp; 263 PRTUTF16 pwszOld = pwsz; 264 RTUtf16GetCpEx((PCRTUTF16 *)&pwsz, &Cp); 265 if (!Cp) 266 break; 267 for (pCp = puszValidSet; ; ++pCp) 268 if (!*pCp || *pCp == Cp) 269 break; 270 if (!*pCp) 271 { 272 for (; pwszOld != pwsz; ++pwszOld) 273 *pwszOld = chReplacement; 274 ++cReplacements; 275 } 276 } 277 return cReplacements; 278 } 279 RT_EXPORT_SYMBOL(RTUtf16PurgeComplementSet); 280 281 252 282 /** 253 283 * Validate the UTF-16 encoding and calculates the length of an UTF-8 encoding. -
trunk/src/VBox/Runtime/common/string/utf-8.cpp
r36555 r40071 350 350 } 351 351 RT_EXPORT_SYMBOL(RTStrPurgeEncoding); 352 353 354 ssize_t RTStrPurgeComplementSet(char *psz, PCRTUNICP puszValidSet, char chReplacement) 355 { 356 size_t cReplacements = 0; 357 AssertReturn(chReplacement && (unsigned)chReplacement < 128, -1); 358 if (RT_FAILURE(RTStrValidateEncoding(psz))) 359 return -1; 360 for (;;) 361 { 362 RTUNICP Cp; 363 PCRTUNICP pCp; 364 char *pszOld = psz; 365 RTStrGetCpEx((const char **)&psz, &Cp); 366 if (!Cp) 367 break; 368 for (pCp = puszValidSet; ; ++pCp) 369 if (!*pCp || *pCp == Cp) 370 break; 371 if (!*pCp) 372 { 373 for (; pszOld != psz; ++pszOld) 374 *pszOld = chReplacement; 375 ++cReplacements; 376 } 377 } 378 return cReplacements; 379 } 380 RT_EXPORT_SYMBOL(RTStrPurgeComplementSet); 352 381 353 382
Note:
See TracChangeset
for help on using the changeset viewer.