VirtualBox

Ignore:
Timestamp:
May 24, 2024 12:56:32 PM (9 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Make ShClUtf16LFLenUtf8 to provide proper length in characters for LF -> CRLF conversion, bugref:10694.

Also rename the function into ShClUtf16CalcNormalizedEolToCRLFLength and update documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r104762 r104773  
    668668    size_t   cchDst;
    669669
    670     int rc = ShClUtf16LFLenUtf8(pcwszSrc, cwcSrc, &cchDst);
     670    int rc = ShClUtf16CalcNormalizedEolToCRLFLength(pcwszSrc, cwcSrc, &cchDst);
    671671    if (RT_SUCCESS(rc))
    672672    {
     
    838838}
    839839
    840 int ShClUtf16LFLenUtf8(PCRTUTF16 pcwszSrc, size_t cwSrc, size_t *pchLen)
     840int ShClUtf16CalcNormalizedEolToCRLFLength(PCRTUTF16 pcwszSrc, size_t cwSrc, size_t *pchLen)
    841841{
    842842    AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER);
     
    856856    {
    857857        /* Check for a single line feed */
    858         if (pcwszSrc[i] == VBOX_SHCL_LINEFEED)
     858        if (   pcwszSrc[i] == VBOX_SHCL_LINEFEED
     859            && (i == 0 || pcwszSrc[i - 1] != VBOX_SHCL_CARRIAGERETURN))
     860        {
    859861            ++cLen;
     862        }
    860863#ifdef RT_OS_DARWIN
    861864        /* Check for a single carriage return (MacOS) */
    862         if (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
     865        if (   pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN
     866            && (i + 1 >= cwcSrc || pcwszSrc[i + 1] != VBOX_SHCL_LINEFEED))
     867        {
    863868            ++cLen;
     869        }
    864870#endif
    865871        if (pcwszSrc[i] == 0)
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