Changeset 249 for trunk/src/helpers/xstring.c
- Timestamp:
- Feb 8, 2003, 9:57:38 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/xstring.c
r245 r249 1258 1258 1259 1259 // static encoding table for xstrEncode 1260 STATICPSZ apszEncoding[] =1260 static PSZ apszEncoding[] = 1261 1261 { 1262 1262 "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07", … … 1365 1365 // use the static encoding table for speed 1366 1366 memcpy(pszDestCurr, 1367 apszEncoding[( unsigned char)pcszEncode[ulEncode]],1367 apszEncoding[(UCHAR)pcszEncode[ulEncode]], 1368 1368 3); 1369 1369 pszDestCurr += 3; … … 1385 1385 *pszDestCurr = 0; 1386 1386 1387 xstrcpy(pxstr, pszDest, pszDestCurr-pszDest); 1387 xstrcpy(pxstr, pszDest, pszDestCurr - pszDest); 1388 } 1389 1390 free(pszDest); 1391 } 1392 1393 return ulrc; 1394 } 1395 1396 /* 1397 *@@ xstrEncodeASCII: 1398 * like xstrEncode, but instead of encoding characters 1399 * from an array given by the caller, this encodes all 1400 * non-ASCII characters (i.e. >= 128) plus the '%' char. 1401 * 1402 *@@added V1.0.2 (2003-02-07) [umoeller] 1403 */ 1404 1405 ULONG xstrEncodeASCII(PXSTRING pxstr) // in/out: string to convert 1406 { 1407 ULONG ulrc = 0, 1408 ul, 1409 ulEncodeLength; 1410 1411 if ( (pxstr) 1412 && (pxstr->ulLength) 1413 ) 1414 { 1415 PSZ pszDest = (PSZ)malloc(pxstr->ulLength * 3 1416 + 1), 1417 pszDestCurr = pszDest; 1418 1419 if (pszDest) 1420 { 1421 for (ul = 0; 1422 ul < pxstr->ulLength; 1423 ul++) 1424 { 1425 if ( ((UCHAR)pxstr->psz[ul] >= 128) 1426 || (pxstr->psz[ul] == '%') 1427 ) 1428 { 1429 memcpy(pszDestCurr, 1430 apszEncoding[(UCHAR)pxstr->psz[ul]], 1431 3); 1432 pszDestCurr += 3; 1433 ulrc++; 1434 goto iterate; 1435 } 1436 1437 *pszDestCurr++ = pxstr->psz[ul]; 1438 1439 iterate: 1440 ; 1441 } 1442 } 1443 1444 // something was encoded; update pxstr 1445 if (ulrc) 1446 { 1447 *pszDestCurr = 0; 1448 1449 xstrcpy(pxstr, pszDest, pszDestCurr - pszDest); 1388 1450 } 1389 1451
Note:
See TracChangeset
for help on using the changeset viewer.