Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / helpcompiler / source / LuceneHelper.cxx
blob7002162a7862091b7ffbd00198184511fada29e2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include "LuceneHelper.hxx"
12 std::vector<TCHAR> OUStringToTCHARVec(OUString const &rStr)
14 //UTF-16
15 if (sizeof(TCHAR) == sizeof(sal_Unicode))
16 return std::vector<TCHAR>(rStr.getStr(), rStr.getStr() + rStr.getLength() + 1);
18 //UTF-32
19 std::vector<TCHAR> aRet;
20 for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength(); )
22 const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
23 aRet.push_back(nCode);
25 aRet.push_back(0);
26 return aRet;
29 OUString TCHARArrayToOUString(TCHAR const *str)
31 // UTF-16
32 if (sizeof(TCHAR) == sizeof(sal_Unicode))
33 return OUString(reinterpret_cast<const sal_Unicode*>(str));
35 // UTF-32
36 return OUString(reinterpret_cast<const sal_uInt32*>(str), wcslen(str));
39 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */