LibreOffice Module o3tl (master) 1
runtimetooustring.hxx
Go to the documentation of this file.
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.
4 *
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 */
9
10#ifndef INCLUDED_O3TL_RUNTIMETOOUSTRING_HXX
11#define INCLUDED_O3TL_RUNTIMETOOUSTRING_HXX
12
13#include <sal/config.h>
14
15#include <cassert>
16#include <cstring>
17
18#include <rtl/textcvt.h>
19#include <rtl/textenc.h>
20#include <rtl/ustring.h>
21#include <rtl/ustring.hxx>
22
23namespace o3tl
24{
32inline OUString runtimeToOUString(char const* runtimeString)
33{
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;
42}
43}
44
45#endif
46
47/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
OUString runtimeToOUString(char const *runtimeString)
Convert an NTBS from the C++ runtime to an OUString.