Changeset 21714 in vbox for trunk/include/iprt
- Timestamp:
- Jul 17, 2009 11:22:40 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50274
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/string.h
r21642 r21714 1533 1533 1534 1534 /** 1535 * Free a UTF-16 string allocated by RTStr Utf8ToUtf16(), RTStrUtf8ToUtf16Ex(),1536 * RT Utf16Dup() or RTUtf16DupEx().1535 * Free a UTF-16 string allocated by RTStrToUtf16(), RTStrToUtf16Ex(), 1536 * RTLatin1ToUtf16(), RTLatin1ToUtf16Ex(), RTUtf16Dup() or RTUtf16DupEx(). 1537 1537 * 1538 1538 * @returns iprt status code. … … 1707 1707 1708 1708 /** 1709 * Translate a UTF-16 string into a Latin1 allocating the result buffer. 1710 * 1711 * @returns iprt status code. 1712 * @param pwszString UTF-16 string to convert. 1713 * @param ppszString Receives pointer of allocated Latin1 string on 1714 * success, and is always set to NULL on failure. 1715 * The returned pointer must be freed using RTStrFree(). 1716 */ 1717 RTDECL(int) RTUtf16ToLatin1(PCRTUTF16 pwszString, char **ppszString); 1718 1719 /** 1720 * Translates UTF-16 to Latin1 using buffer provided by the caller or 1721 * a fittingly sized buffer allocated by the function. 1722 * 1723 * @returns iprt status code. 1724 * @param pwszString The UTF-16 string to convert. 1725 * @param cwcString The number of RTUTF16 items to translate from pwszString. 1726 * The translation will stop when reaching cwcString or the terminator ('\\0'). 1727 * Use RTSTR_MAX to translate the entire string. 1728 * @param ppsz If cch is non-zero, this must either be pointing to a pointer to 1729 * a buffer of the specified size, or pointer to a NULL pointer. 1730 * If *ppsz is NULL or cch is zero a buffer of at least cch chars 1731 * will be allocated to hold the translated string. 1732 * If a buffer was requested it must be freed using RTUtf16Free(). 1733 * @param cch The buffer size in chars (the type). This includes the terminator. 1734 * @param pcch Where to store the length of the translated string. (Optional) 1735 * This field will be updated even on failure, however the value is only 1736 * specified for the following two error codes. On VERR_BUFFER_OVERFLOW 1737 * and VERR_NO_STR_MEMORY it contains the required buffer space. 1738 */ 1739 RTDECL(int) RTUtf16ToLatin1Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch); 1740 1741 /** 1742 * Calculates the length of the UTF-16 string in Latin1 chars (bytes). 1743 * 1744 * This function will validate the string, and incorrectly encoded UTF-16 1745 * strings will be rejected. The primary purpose of this function is to 1746 * help allocate buffers for RTUtf16ToLatin1() of the correct size. For most 1747 * other purposes RTUtf16ToLatin1Ex() should be used. 1748 * 1749 * @returns Number of char (bytes). 1750 * @returns 0 if the string was incorrectly encoded. 1751 * @param pwsz The UTF-16 string. 1752 */ 1753 RTDECL(size_t) RTUtf16CalcLatin1Len(PCRTUTF16 pwsz); 1754 1755 /** 1756 * Calculates the length of the UTF-16 string in Latin1 chars (bytes). 1757 * 1758 * This function will validate the string, and incorrectly encoded UTF-16 1759 * strings will be rejected. 1760 * 1761 * @returns iprt status code. 1762 * @param pwsz The string. 1763 * @param cwc The max string length. Use RTSTR_MAX to process the entire string. 1764 * @param pcch Where to store the string length (in bytes). Optional. 1765 * This is undefined on failure. 1766 */ 1767 RTDECL(int) RTUtf16CalcLatin1LenEx(PCRTUTF16 pwsz, size_t cwc, size_t *pcch); 1768 1769 /** 1770 * Calculates the length of the string in RTUTF16 items. 1771 * 1772 * @returns Number of RTUTF16 items. 1773 * @param psz The string. 1774 */ 1775 RTDECL(size_t) RTLatin1CalcUtf16Len(const char *psz); 1776 1777 /** 1778 * Calculates the length of the string in RTUTF16 items. 1779 * 1780 * @returns iprt status code. 1781 * @param psz The string. 1782 * @param cch The max string length. Use RTSTR_MAX to process the entire string. 1783 * @param pcwc Where to store the string length. Optional. 1784 * This is undefined on failure. 1785 */ 1786 RTDECL(int) RTLatin1CalcUtf16LenEx(const char *psz, size_t cch, size_t *pcwc); 1787 1788 /** 1789 * Translate a Latin1 string into a UTF-16 allocating the result buffer. 1790 * 1791 * @returns iprt status code. 1792 * @param pszString Latin1 string to convert. 1793 * @param ppwszString Receives pointer to the allocated UTF-16 string. 1794 * The returned string must be freed using 1795 * RTUtf16Free(). 1796 */ 1797 RTDECL(int) RTLatin1ToUtf16(const char *pszString, PRTUTF16 *ppwszString); 1798 1799 /** 1800 * Translates pszString from Latin1 to UTF-16, allocating the result buffer 1801 * if requested. 1802 * 1803 * @returns iprt status code. 1804 * @param pszString Latin1 string to convert. 1805 * @param cchString The maximum size in chars (the type) to convert. 1806 * The conversion stops when it reaches cchString or 1807 * the string terminator ('\\0'). 1808 * Use RTSTR_MAX to translate the entire string. 1809 * @param ppwsz If cwc is non-zero, this must either be pointing 1810 * to pointer to a buffer of the specified size, or 1811 * pointer to a NULL pointer. 1812 * If *ppwsz is NULL or cwc is zero a buffer of at 1813 * least cwc items will be allocated to hold the 1814 * translated string. If a buffer was requested it 1815 * must be freed using RTUtf16Free(). 1816 * @param cwc The buffer size in RTUTF16s. This includes the 1817 * terminator. 1818 * @param pcwc Where to store the length of the translated 1819 * string. (Optional) 1820 * This field will be updated even on failure, 1821 * however the value is only specified for the 1822 * following two error codes. On VERR_BUFFER_OVERFLOW 1823 * and VERR_NO_STR_MEMORY it contains the required 1824 * buffer space. 1825 */ 1826 RTDECL(int) RTLatin1ToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc); 1827 1828 /** 1709 1829 * Get the unicode code point at the given string position. 1710 1830 *
Note:
See TracChangeset
for help on using the changeset viewer.