Changeset 594 for vendor/current/source3/lib/util_str.c
- Timestamp:
- Jul 1, 2011, 4:02:23 PM (14 years ago)
- File:
-
- 1 edited
-
vendor/current/source3/lib/util_str.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/util_str.c
r414 r594 1455 1455 1456 1456 /** 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1457 1533 Count the number of UCS2 characters in a string. Normally this will 1458 1534 be the same as the number of bytes in a string for single byte strings, … … 1462 1538 size_t strlen_m(const char *s) 1463 1539 { 1464 size_t count = 0; 1465 1466 if (!s) { 1467 return 0; 1468 } 1469 1470 while (*s && !(((uint8_t)*s) & 0x80)) { 1471 s++; 1472 count++; 1473 } 1474 1475 if (!*s) { 1476 return count; 1477 } 1478 1479 while (*s) { 1480 size_t c_size; 1481 codepoint_t c = next_codepoint(s, &c_size); 1482 if (c < 0x10000) { 1483 /* Unicode char fits into 16 bits. */ 1484 count += 1; 1485 } else { 1486 /* Double-width unicode char - 32 bits. */ 1487 count += 2; 1488 } 1489 s += c_size; 1490 } 1491 1492 return count; 1540 return strlen_m_ext(s, CH_UTF16LE); 1493 1541 } 1494 1542
Note:
See TracChangeset
for help on using the changeset viewer.
