VirtualBox

Changeset 85828 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Aug 19, 2020 9:12:33 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139986
Message:

Shared Clipboard/X11: Major cleanup for string conversion functions. Not fully tested yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/clipboard-helper.h

    r82968 r85828  
    4949
    5050/**
    51  * Get the size of the buffer needed to hold a UTF-16-LE zero terminated string
    52  * with Windows EOLs converted from a UTF-16 string with Linux EOLs.
    53  *
    54  * @returns VBox status code.
    55  * @param   pcwszSrc The source UTF-16 string.
    56  * @param   cwcSrc   The length of the source string in RTUTF16 units.
    57  * @param   pcwcDst  The length of the destination string in RTUTF16 units.
    58  */
    59 int ShClUtf16GetWinSize(PCRTUTF16 pcwszSrc, size_t cwcSrc, size_t *pcwcDst);
    60 
    61 /**
    62  * Convert a UTF-16 text with Linux EOLs to null-terminated UTF-16-LE with
    63  * Windows EOLs.
    64  *
    65  * Does no checking for validity.
    66  *
    67  * @returns VBox status code.
    68  * @param   pcwszSrc Source UTF-16 text to convert.
    69  * @param   cwcSrc   Size of the source text int RTUTF16 units.
    70  * @param   pwszDst  Buffer to store the converted text to.
    71  * @param   cwcDst   Size of the buffer for the converted text in RTUTF16 units.
    72  */
    73 int ShClUtf16LinToWin(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
    74 
    75 /**
    76  * Get the size of the buffer needed to hold a zero-terminated UTF-16 string
    77  * with Linux EOLs converted from a UTF-16 string with Windows EOLs.
    78  *
    79  * @returns VBox status code.
    80  * @param   pcwszSrc The source UTF-16 string.
    81  * @param   cwcSrc   The length of the source string in RTUTF16 units.
    82  * @param   pcwcDst  The length of the destination string in RTUTF16 units.
    83  */
    84 int ShClUtf16GetLinSize(PCRTUTF16 pcwszSrc, size_t cwcSrc, size_t *pcwcDst);
    85 
    86 /**
    87  * Convert UTF-16-LE text with Windows EOLs to zero-terminated UTF-16 with Linux
    88  * EOLs.  This function does not verify that the UTF-16 is valid.
    89  *
    90  * @returns VBox status code.
    91  * @param   pcwszSrc Text to convert.
    92  * @param   cwcSrc   Size of the source text in RTUTF16 units.
    93  * @param   pwszDst  The buffer to store the converted text to.
    94  * @param   cwcDst   The size of the buffer for the destination text in RTUTF16 chars.
    95  */
    96 int ShClUtf16WinToLin(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
     51 * Returns the length (in UTF-8 characters) of an UTF-16 string with LF EOL.
     52 *
     53 * @returns VBox status code.
     54 * @param   pcwszSrc            UTF-16 string to return size for.
     55 * @param   cwcSrc              Length of the string in RTUTF16 units.
     56 * @param   pchLen              Where to return the length (in UTF-8 characters). Includes terminator.
     57 */
     58int ShClUtf16LFLenUtf8(PCRTUTF16 pcwszSrc, size_t cwcSrc, size_t *pchLen);
     59
     60/**
     61 * Returns the length (in UTF-8 characters) of an UTF-16 string with CRLF EOL.
     62 *
     63 * @returns VBox status code.
     64 * @param   pcwszSrc            UTF-16 string to return size for.
     65 * @param   cwcSrc              Length of the source string in RTUTF16 units.
     66 * @param   pchLen              Where to return the length (in UTF-8 characters). Includes terminator.
     67 */
     68int ShClUtf16CRLFLenUtf8(PCRTUTF16 pcwszSrc, size_t cwcSrc, size_t *pchLen);
     69
     70/**
     71 * Returns the length (in characters) of an UTF-16 string, including terminator.
     72 *
     73 * @returns VBox status code.
     74 * @param  pcwszSrc             UTF-16 string to return size for.
     75 * @param  cwcSrc               Length of the source string in RTUTF16 units.
     76 * @param  pchLen               Where to return the length (in UTF-8 characters). Includes terminator.
     77 */
     78int ShClUtf16LenUtf8(PCRTUTF16 pcwszSrc, size_t cwcSrc, size_t *pchLen);
     79
     80/**
     81 * Converts an UTF-16 string with LF EOL to an UTF-16 string with CRLF EOL.
     82 *
     83 * @returns VBox status code.
     84 * @param   pcwszSrc            UTF-16 string to convert.
     85 * @param   cwcSrc              Size of the string int RTUTF16 units.
     86 * @param   pwszDst             Buffer to store the converted string to.
     87 * @param   cwcDst              Size of the buffer for the converted string in RTUTF16 units. Includes terminator.
     88 */
     89int ShClConvUtf16LFToCRLF(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
     90
     91/**
     92 * Converts an UTF-16 string with LF EOL to an UTF-16 string with CRLF EOL.
     93 *
     94 * Convenience function which returns the allocated + converted string on success.
     95 *
     96 * @returns VBox status code.
     97 * @param   pcwszSrc            UTF-16 string to convert.
     98 * @param   cwcSrc              Size of the string int RTUTF16 units.
     99 * @param   pwszDst             Where to return the allocated converted string. Must be free'd by the caller.
     100 * @param   cwcDst              Where to return the size of the converted string in RTUTF16 units. Includes terminator.
     101 */
     102int ShClConvUtf16LFToCRLFA(RTUTF16 *pwcSrc, size_t cwcSrc, PRTUTF16 *ppwszDst, size_t *pcwDst);
     103
     104/**
     105 * Converts an UTF-16 string with CRLF EOL to an UTF-16 string with LF EOL.
     106 *
     107 * @returns VBox status code.
     108 * @param   pcwszSrc            UTF-16 string to convert.
     109 * @param   cwcSrc              Size of the string in RTUTF16 units.
     110 * @param   pwszDst             Where to store the converted string to.
     111 * @param   cwcDst              The size of \a pwszDst in RTUTF16 chars. Includes terminator.
     112 */
     113int ShClConvUtf16CRLFToLF(PCRTUTF16 pcwszSrc, size_t cwcSrc, PRTUTF16 pwszDst, size_t cwcDst);
     114
     115/**
     116 * Converts an UTF-16 string with CRLF EOL to UTF-8 LF.
     117 *
     118 * @returns VBox status code. Will return VERR_NO_DATA if no data was converted.
     119 * @param  pwszSrc              UTF-16 string to convert.
     120 * @param  cbSrc                Length of @a pwszSrc (in bytes).
     121 * @param  pszBuf               Where to write the converted string.
     122 * @param  cbBuf                The size of the buffer pointed to by @a pszBuf.
     123 * @param  pcbLen               Where to store the size (in bytes) of the converted string. Includes terminator.
     124 */
     125int ShClConvUtf16CRLFToUtf8LF(PRTUTF16 pwszSrc, size_t cbSrc, char *pszBuf, size_t cbBuf, size_t *pcbLen);
     126
     127/**
     128* Converts an HTML string from UTF-16 into UTF-8.
     129*
     130* @returns VBox status code.
     131* @param  pwcSrc                The source text.
     132* @param  cwSrc                 Length (in RTUTF16 units) of the source text.
     133* @param  ppszDst               Where to store the converted result on success.
     134* @param  pcbDst                Where to store the number of bytes written.
     135*/
     136int ShClConvUtf16ToUtf8HTML(RTUTF16 *pwcSrc, size_t cwSrc, char **ppszDst, size_t *pcbDst);
     137
     138/**
     139 * Converts an UTF-8 string with LF EOL into UTF-16 CRLF.
     140 *
     141 * @returns VBox status code.
     142 * @param  pszSrc               UTF-8 string to convert.
     143 * @param  cbSrc                Size of UTF-8 string to convert (in bytes), not counting the terminating zero.
     144 * @param  ppwszDst             Where to return the allocated buffer on success.
     145 * @param  pcwDst               Where to return the size (in RTUTF16 units) of the allocated buffer on success. Includes terminator.
     146 */
     147int ShClConvUtf8LFToUtf16CRLF(const char *pszSrc, unsigned cbSrc, PRTUTF16 *ppwszDst, size_t *pcwDst);
     148
     149/**
     150 * Converts a Latin-1 string with LF EOL into UTF-16 CRLF.
     151 *
     152 * @returns VBox status code.
     153 * @param  pszSrc               UTF-8 string to convert.
     154 * @param  cbSrc                Size of string (in bytes), not counting the terminating zero.
     155 * @param  ppwszDst             Where to return the allocated buffer on success.
     156 * @param  pcwDst               Where to return the size (in RTUTF16 units) of the allocated buffer on success. Includes terminator.
     157 */
     158int ShClConvLatin1LFToUtf16CRLF(const char *pszSrc, unsigned cbSrc, PRTUTF16 *ppwszDst, size_t *pcwDst);
    97159
    98160#pragma pack(1)
Note: See TracChangeset for help on using the changeset viewer.

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