VirtualBox

Changeset 67334 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jun 12, 2017 9:48:11 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116047
Message:

IPRT: Added RTStrToUtf16BigEx and RTStrToUtf16Big for turning UTF-8 into UTF-16BE (big endian).

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r67284 r67334  
    19521952# define RTStrToUniEx                                   RT_MANGLER(RTStrToUniEx)
    19531953# define RTStrToUpper                                   RT_MANGLER(RTStrToUpper)
     1954# define RTStrToUtf16BigExTag                           RT_MANGLER(RTStrToUtf16BigExTag)
     1955# define RTStrToUtf16BigTag                             RT_MANGLER(RTStrToUtf16BigTag)
    19541956# define RTStrToUtf16ExTag                              RT_MANGLER(RTStrToUtf16ExTag)
    19551957# define RTStrToUtf16Tag                                RT_MANGLER(RTStrToUtf16Tag)
  • trunk/include/iprt/string.h

    r66882 r67334  
    830830 * tag).
    831831 *
     832 * This differs from RTStrToUtf16 in that it always produces a
     833 * big-endian string.
     834 *
    832835 * @returns iprt status code.
    833836 * @param   pszString       UTF-8 string to convert.
     
    837840 */
    838841RTDECL(int) RTStrToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
     842
     843/**
     844 * Translate a UTF-8 string into a UTF-16BE allocating the result buffer
     845 * (default tag).
     846 *
     847 * This differs from RTStrToUtf16Tag in that it always produces a
     848 * big-endian string.
     849 *
     850 * @returns iprt status code.
     851 * @param   pszString       UTF-8 string to convert.
     852 * @param   ppwszString     Receives pointer to the allocated UTF-16BE string.
     853 *                          The returned string must be freed using RTUtf16Free().
     854 */
     855#define RTStrToUtf16Big(pszString, ppwszString)  RTStrToUtf16BigTag((pszString), (ppwszString), RTSTR_TAG)
     856
     857/**
     858 * Translate a UTF-8 string into a UTF-16BE allocating the result buffer (custom
     859 * tag).
     860 *
     861 * @returns iprt status code.
     862 * @param   pszString       UTF-8 string to convert.
     863 * @param   ppwszString     Receives pointer to the allocated UTF-16BE string.
     864 *                          The returned string must be freed using RTUtf16Free().
     865 * @param   pszTag          Allocation tag used for statistics and such.
     866 */
     867RTDECL(int) RTStrToUtf16BigTag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
    839868
    840869/**
     
    887916 * @param   pszTag          Allocation tag used for statistics and such.
    888917 */
    889 RTDECL(int)  RTStrToUtf16ExTag(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
     918RTDECL(int)  RTStrToUtf16ExTag(const char *pszString, size_t cchString,
     919                               PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
     920
     921
     922/**
     923 * Translates pszString from UTF-8 to UTF-16BE, allocating the result buffer if requested.
     924 *
     925 * This differs from RTStrToUtf16Ex in that it always produces a
     926 * big-endian string.
     927 *
     928 * @returns iprt status code.
     929 * @param   pszString       UTF-8 string to convert.
     930 * @param   cchString       The maximum size in chars (the type) to convert. The conversion stop
     931 *                          when it reaches cchString or the string terminator ('\\0').
     932 *                          Use RTSTR_MAX to translate the entire string.
     933 * @param   ppwsz           If cwc is non-zero, this must either be pointing to pointer to
     934 *                          a buffer of the specified size, or pointer to a NULL pointer.
     935 *                          If *ppwsz is NULL or cwc is zero a buffer of at least cwc items
     936 *                          will be allocated to hold the translated string.
     937 *                          If a buffer was requested it must be freed using RTUtf16Free().
     938 * @param   cwc             The buffer size in RTUTF16s. This includes the terminator.
     939 * @param   pcwc            Where to store the length of the translated string,
     940 *                          excluding the terminator. (Optional)
     941 *
     942 *                          This may be set under some error conditions,
     943 *                          however, only for VERR_BUFFER_OVERFLOW and
     944 *                          VERR_NO_STR_MEMORY will it contain a valid string
     945 *                          length that can be used to resize the buffer.
     946 */
     947#define RTStrToUtf16BigEx(pszString, cchString, ppwsz, cwc, pcwc) \
     948    RTStrToUtf16BigExTag((pszString), (cchString), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
     949
     950/**
     951 * Translates pszString from UTF-8 to UTF-16BE, allocating the result buffer if
     952 * requested (custom tag).
     953 *
     954 * This differs from RTStrToUtf16ExTag in that it always produces a
     955 * big-endian string.
     956 *
     957 * @returns iprt status code.
     958 * @param   pszString       UTF-8 string to convert.
     959 * @param   cchString       The maximum size in chars (the type) to convert. The conversion stop
     960 *                          when it reaches cchString or the string terminator ('\\0').
     961 *                          Use RTSTR_MAX to translate the entire string.
     962 * @param   ppwsz           If cwc is non-zero, this must either be pointing to pointer to
     963 *                          a buffer of the specified size, or pointer to a NULL pointer.
     964 *                          If *ppwsz is NULL or cwc is zero a buffer of at least cwc items
     965 *                          will be allocated to hold the translated string.
     966 *                          If a buffer was requested it must be freed using RTUtf16Free().
     967 * @param   cwc             The buffer size in RTUTF16s. This includes the terminator.
     968 * @param   pcwc            Where to store the length of the translated string,
     969 *                          excluding the terminator. (Optional)
     970 *
     971 *                          This may be set under some error conditions,
     972 *                          however, only for VERR_BUFFER_OVERFLOW and
     973 *                          VERR_NO_STR_MEMORY will it contain a valid string
     974 *                          length that can be used to resize the buffer.
     975 * @param   pszTag          Allocation tag used for statistics and such.
     976 */
     977RTDECL(int)  RTStrToUtf16BigExTag(const char *pszString, size_t cchString,
     978                                  PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
    890979
    891980
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette