Line data Source code
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 :
12 0 : std::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 0 : std::vector<TCHAR> aRet;
20 0 : for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength(); )
21 : {
22 0 : const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
23 0 : aRet.push_back(nCode);
24 : }
25 0 : aRet.push_back(0);
26 0 : return aRet;
27 : }
28 :
29 0 : OUString TCHARArrayToOUString(TCHAR const *str)
30 : {
31 : // UTF-16
32 : if (sizeof(TCHAR) == sizeof(sal_Unicode))
33 : return OUString((const sal_Unicode*)(str));
34 :
35 : // UTF-32
36 0 : return OUString((const sal_uInt32*)str, wcslen(str));
37 : }
38 :
39 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|