LibreOffice Module helpcompiler (master) 1
LuceneHelper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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#include "LuceneHelper.hxx"
11
12std::vector<TCHAR> OUStringToTCHARVec(OUString const& rStr)
13{
14 //UTF-16
15 if (sizeof(TCHAR) == sizeof(sal_Unicode))
16 return std::vector<TCHAR>(rStr.getStr(), rStr.getStr() + rStr.getLength() + 1);
17
18 //UTF-32
19 std::vector<TCHAR> aRet;
20 for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength();)
21 {
22 const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
23 aRet.push_back(nCode);
24 }
25 aRet.push_back(0);
26 return aRet;
27}
28
29OUString TCHARArrayToOUString(TCHAR const* str)
30{
31 // UTF-16
32 if (sizeof(TCHAR) == sizeof(sal_Unicode))
33 return OUString(reinterpret_cast<const sal_Unicode*>(str));
34
35 // UTF-32
36 return OUString(reinterpret_cast<const sal_uInt32*>(str), wcslen(str));
37}
38
39/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString TCHARArrayToOUString(TCHAR const *str)
std::vector< TCHAR > OUStringToTCHARVec(OUString const &rStr)
sal_uInt16 sal_Unicode