CppunitTest_vcl_pdfexport2: relax testPdfImageHyperlink a bit
[LibreOffice.git] / include / o3tl / runtimetooustring.hxx
blob6d6f27ac186e1bfd0074743378af2cae39a9769d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_O3TL_RUNTIMETOOUSTRING_HXX
11 #define INCLUDED_O3TL_RUNTIMETOOUSTRING_HXX
13 #include <sal/config.h>
15 #include <cassert>
16 #include <cstring>
18 #include <rtl/textcvt.h>
19 #include <rtl/textenc.h>
20 #include <rtl/ustring.h>
21 #include <rtl/ustring.hxx>
23 namespace o3tl
25 /** Convert an NTBS from the C++ runtime to an OUString.
27 This is used to convert an NTBS as provided by std::exception::what or
28 std::type_info::name into an OUString in a "lossless" way. The conversion
29 is done using RTL_TEXTENCODING_ISO_8859_1, so each char in the input maps
30 to one Unicode character in the output.
32 inline OUString runtimeToOUString(char const* runtimeString)
34 OUString s;
35 bool ok = rtl_convertStringToUString(
36 &s.pData, runtimeString, std::strlen(runtimeString), RTL_TEXTENCODING_ISO_8859_1,
37 (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
38 | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR));
39 assert(ok);
40 (void)ok;
41 return s;
45 #endif
47 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */