Improve some OUString to OString conversions

...dropping an intermediary OUString temporary (assuming that way of
constructing an OUString temporary from a pointer was not chosen deliberately to
cut of the string at a potential embedded NUL).

(This change is a prerequisite for making the OUString ctor taking a raw pointer
explicit.)

Change-Id: I752a0e63b86cb5e3d1a97ede1d855b9602a353c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102081
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2020-09-05 18:25:07 +02:00
parent 125b3ab347
commit aa357e56e8

View File

@ -1383,7 +1383,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
std::unique_ptr<sal_Unicode[]> value(new sal_Unicode[size]); std::unique_ptr<sal_Unicode[]> value(new sal_Unicode[size]);
readString(aBuffer.data(), value.get(), size); readString(aBuffer.data(), value.get(), size);
OString uStr = OUStringToOString(value.get(), RTL_TEXTENCODING_UTF8); OString uStr(value.get(), rtl_ustr_getLength(value.get()), RTL_TEXTENCODING_UTF8);
fprintf(stdout, "L\"%s\"\n", uStr.getStr()); fprintf(stdout, "L\"%s\"\n", uStr.getStr());
} }
break; break;
@ -1498,7 +1498,7 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
if (offset > 8) if (offset > 8)
fprintf(stdout, "%s ", indent); fprintf(stdout, "%s ", indent);
uStr = OUStringToOString(pValue, RTL_TEXTENCODING_UTF8); uStr = OString(pValue, rtl_ustr_getLength(pValue), RTL_TEXTENCODING_UTF8);
fprintf( fprintf(
stdout, "%lu = L\"%s\"\n", stdout, "%lu = L\"%s\"\n",
sal::static_int_cast< unsigned long >(i), sal::static_int_cast< unsigned long >(i),