Changeset 35567 in vbox for trunk/include/iprt/cpp
- Timestamp:
- Jan 14, 2011 2:16:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/ministring.h
r35128 r35567 185 185 * String length in bytes. 186 186 * 187 * Returns the length of the member string , which is equal to strlen(c_str()).188 * In other words, this does not count unicode codepoints but returns the number189 * of bytes. Thisis always cached so calling this is cheap and requires no187 * Returns the length of the member string in bytes, which is equal to strlen(c_str()). 188 * In other words, this does not count unicode codepoints; use utf8length() for that. 189 * The byte length is always cached so calling this is cheap and requires no 190 190 * strlen() invocation. 191 191 * … … 195 195 { 196 196 return m_cch; 197 } 198 199 /** 200 * String length in UTF-8 codepoints. 201 * 202 * As opposed to length(), which returns the length in bytes, this counts the number 203 * of UTF-8 codepoints. This is *not* cached so calling this is expensive. 204 * 205 * @returns Number of codepoints in the member string. 206 */ 207 size_t utf8length() const 208 { 209 return m_psz ? RTStrUniLen(m_psz) : 0; 197 210 } 198 211 … … 652 665 * Find the given substring. 653 666 * 654 * Looks for pcszFind in "this" starting at "pos" and returns its position ,655 * counting from the beginning of "this" at 0.667 * Looks for pcszFind in "this" starting at "pos" and returns its position 668 * as a byte (not codepoint) offset, counting from the beginning of "this" at 0. 656 669 * 657 670 * @param pcszFind The substring to find. … … 676 689 * Returns a substring of "this" as a new Utf8Str. 677 690 * 678 * Works exactly like its equivalent in std::string except that this interprets 679 * pos and n as unicode codepoints instead of bytes. With the default 680 * parameters "0" and "npos", this always copies the entire string. 691 * Works exactly like its equivalent in std::string. With the default 692 * parameters "0" and "npos", this always copies the entire string. The 693 * "pos" and "n" arguments represent bytes; it is the caller's responsibility 694 * to ensure that the offsets do not copy invalid UTF-8 sequences. When 695 * used in conjunction with find() and length(), this will work. 696 * 697 * @param pos Index of first byte offset to copy from "this", counting from 0. 698 * @param n Number of bytes to copy, starting with the one at "pos". 699 * The copying will stop if the null terminator is encountered before 700 * n bytes have been copied. 701 */ 702 iprt::MiniString substr(size_t pos = 0, size_t n = npos) const 703 { 704 return MiniString(*this, pos, n); 705 } 706 707 /** 708 * Returns a substring of "this" as a new Utf8Str. As opposed to substr(), 709 * this variant takes codepoint offsets instead of byte offsets. 681 710 * 682 711 * @param pos Index of first unicode codepoint to copy from … … 686 715 * terminator is encountered before n codepoints have 687 716 * been copied. 688 * 689 * @remarks This works on code points, not bytes! 690 */ 691 iprt::MiniString substr(size_t pos = 0, size_t n = npos) const; 717 */ 718 iprt::MiniString substrCP(size_t pos = 0, size_t n = npos) const; 692 719 693 720 /**
Note:
See TracChangeset
for help on using the changeset viewer.