VirtualBox

Changeset 78732 in vbox for trunk/src


Ignore:
Timestamp:
May 24, 2019 3:28:44 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/string: Implemented RTUtf16CopyEx.

Location:
trunk/src/VBox/Runtime
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r78702 r78732  
    571571        common/string/RTUtf16Copy.cpp \
    572572        common/string/RTUtf16CopyAscii.cpp \
     573        common/string/RTUtf16CopyEx.cpp \
    573574        common/string/RTUtf16Cat.cpp \
    574575        common/string/RTUtf16CatAscii.cpp \
     
    29142915        common/string/RTUtf16Copy.cpp \
    29152916        common/string/RTUtf16CopyAscii.cpp \
     2917        common/string/RTUtf16CopyEx.cpp \
    29162918        common/string/RTUtf16Cat.cpp \
    29172919        common/string/RTUtf16CatAscii.cpp \
  • trunk/src/VBox/Runtime/common/string/RTUtf16CopyEx.cpp

    r78704 r78732  
    11/* $Id$ */
    22/** @file
    3  * IPRT - RTUtf16Copy.
     3 * IPRT - RTUtf16CopyEx.
    44 */
    55
     
    3535
    3636
    37 RTDECL(int) RTUtf16Copy(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc)
     37RTDECL(int) RTUtf16CopyEx(PRTUTF16 pwszDst, size_t cwcDst, PCRTUTF16 pwszSrc, size_t cwcSrcMax)
    3838{
    39     size_t wcwSrc = RTUtf16Len(pwszSrc);
    40     if (RT_LIKELY(wcwSrc < cwcDst))
     39    size_t cwcSrc = RTUtf16NLen(pwszSrc, cwcSrcMax);
     40    if (RT_LIKELY(cwcSrc < cwcDst))
    4141    {
    42         memcpy(pwszDst, pwszSrc, (wcwSrc + 1) * sizeof(RTUTF16));
     42        memcpy(pwszDst, pwszSrc, cwcSrc * sizeof(RTUTF16));
     43        pwszDst[cwcSrc] = '\0';
    4344        return VINF_SUCCESS;
    4445    }
     
    5152    return VERR_BUFFER_OVERFLOW;
    5253}
    53 RT_EXPORT_SYMBOL(RTUtf16Copy);
     54RT_EXPORT_SYMBOL(RTUtf16CopyEx);
    5455
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