2012-02-22 03:13:10 -06:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
2013-04-24 11:14:03 -05:00
|
|
|
* This file is part of the LibreOffice project.
|
2012-02-22 03:13:10 -06:00
|
|
|
*
|
2013-04-24 11:14:03 -05:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2012-02-22 03:13:10 -06:00
|
|
|
*/
|
|
|
|
|
2012-04-24 00:42:07 -05:00
|
|
|
#include "LuceneHelper.hxx"
|
2012-02-19 06:49:08 -06:00
|
|
|
|
2013-04-07 05:06:47 -05:00
|
|
|
std::vector<TCHAR> OUStringToTCHARVec(OUString const &rStr)
|
2012-02-19 06:49:08 -06:00
|
|
|
{
|
|
|
|
//UTF-16
|
|
|
|
if (sizeof(TCHAR) == sizeof(sal_Unicode))
|
|
|
|
return std::vector<TCHAR>(rStr.getStr(), rStr.getStr() + rStr.getLength() + 1);
|
|
|
|
|
|
|
|
//UTF-32
|
|
|
|
std::vector<TCHAR> aRet;
|
2012-02-20 14:42:19 -06:00
|
|
|
for (sal_Int32 nStrIndex = 0; nStrIndex < rStr.getLength(); )
|
2012-02-19 06:49:08 -06:00
|
|
|
{
|
|
|
|
const sal_uInt32 nCode = rStr.iterateCodePoints(&nStrIndex);
|
|
|
|
aRet.push_back(nCode);
|
|
|
|
}
|
2012-02-20 14:42:19 -06:00
|
|
|
aRet.push_back(0);
|
2012-02-19 06:49:08 -06:00
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2013-04-07 05:06:47 -05:00
|
|
|
OUString TCHARArrayToOUString(TCHAR const *str)
|
2012-02-19 06:49:08 -06:00
|
|
|
{
|
2012-02-20 14:42:19 -06:00
|
|
|
// UTF-16
|
|
|
|
if (sizeof(TCHAR) == sizeof(sal_Unicode))
|
2013-04-07 05:06:47 -05:00
|
|
|
return OUString((const sal_Unicode*)(str));
|
2012-02-19 06:49:08 -06:00
|
|
|
|
2012-02-20 14:42:19 -06:00
|
|
|
// UTF-32
|
2013-04-07 05:06:47 -05:00
|
|
|
return OUString((const sal_uInt32*)str, wcslen(str));
|
2012-02-19 06:49:08 -06:00
|
|
|
}
|
2012-02-22 03:13:10 -06:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|