VirtualBox

Changeset 80764 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Sep 13, 2019 6:52:50 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133329
Message:

IPRT: Optimized RTEnvPutEx. bugref:9341

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp

    r76553 r80764  
    490490
    491491
    492 RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag)
     492RTR3DECL(int)  RTStrUtf8ToCurrentCPExTag(char **ppszString, const char *pszString, size_t cchString, const char *pszTag)
    493493{
    494494    Assert(ppszString);
     
    497497
    498498    /*
    499      * Attempt with UTF-8 length of 2x the native length.
    500      */
    501     size_t cch = strlen(pszString);
    502     if (cch <= 0)
     499     * Assume result string length is not longer than UTF-8 string.
     500     */
     501    cchString = RTStrNLen(pszString, cchString);
     502    if (cchString < 1)
    503503    {
    504504        /* zero length string passed. */
     
    508508        return VERR_NO_TMP_MEMORY;
    509509    }
     510    return rtStrConvertWrapper(pszString, cchString, "UTF-8", ppszString, 0, "", 1, RTSTRICONV_UTF8_TO_LOCALE);
     511}
     512
     513
     514RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag)
     515{
     516    Assert(ppszString);
     517    Assert(pszString);
     518    *ppszString = NULL;
     519
     520    /*
     521     * Attempt with UTF-8 length of 2x the native length.
     522     */
     523    size_t cch = strlen(pszString);
     524    if (cch <= 0)
     525    {
     526        /* zero length string passed. */
     527        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
     528        if (*ppszString)
     529            return VINF_SUCCESS;
     530        return VERR_NO_TMP_MEMORY;
     531    }
    510532    return rtStrConvertWrapper(pszString, cch, "", ppszString, 0, "UTF-8", 2, RTSTRICONV_LOCALE_TO_UTF8);
    511533}
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