Changeset 258 for branches/branch-1-0/src/helpers/xstring.c
- Timestamp:
- Jan 28, 2004, 9:01:26 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1-0/src/helpers/xstring.c
r222 r258 1392 1392 1393 1393 /* 1394 *@@ xstrEncodeASCII: 1395 * like xstrEncode, but instead of encoding characters 1396 * from an array given by the caller, this encodes all 1397 * non-ASCII characters (i.e. >= 128) plus the '%' char. 1398 * 1399 *@@added V1.0.2 (2003-02-07) [umoeller] 1400 */ 1401 1402 ULONG xstrEncodeASCII(PXSTRING pxstr) // in/out: string to convert 1403 { 1404 ULONG ulrc = 0, 1405 ul, 1406 ulEncodeLength; 1407 1408 if ( (pxstr) 1409 && (pxstr->ulLength) 1410 ) 1411 { 1412 PSZ pszDest = (PSZ)malloc(pxstr->ulLength * 3 1413 + 1), 1414 pszDestCurr = pszDest; 1415 1416 if (pszDest) 1417 { 1418 for (ul = 0; 1419 ul < pxstr->ulLength; 1420 ul++) 1421 { 1422 if ( ((UCHAR)pxstr->psz[ul] >= 128) 1423 || (pxstr->psz[ul] == '%') 1424 ) 1425 { 1426 memcpy(pszDestCurr, 1427 apszEncoding[(UCHAR)pxstr->psz[ul]], 1428 3); 1429 pszDestCurr += 3; 1430 ulrc++; 1431 goto iterate; 1432 } 1433 1434 *pszDestCurr++ = pxstr->psz[ul]; 1435 1436 iterate: 1437 ; 1438 } 1439 } 1440 1441 // something was encoded; update pxstr 1442 if (ulrc) 1443 { 1444 *pszDestCurr = 0; 1445 1446 xstrcpy(pxstr, pszDest, pszDestCurr - pszDest); 1447 } 1448 1449 free(pszDest); 1450 } 1451 1452 return ulrc; 1453 } 1454 1455 /* 1394 1456 *@@ xstrDecode: 1395 1457 * decodes a string previously encoded by xstrEncode.
Note:
See TracChangeset
for help on using the changeset viewer.