Program Listing for File unicode.h

Return to documentation for file (include\utility\unicode.h)

/******************************************************************************
© Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/

#pragma once

#include <wchar.h>

#include "igpa-config.h"

namespace gpa {
namespace utility {

/*
 * Convert from utf8 to utf16
 * @param utf8 [in] input string
 * @return converted string
 */
std::wstring Widen(std::string const& utf8);

/*
 * Convert from utf16 to utf8
 * @param utf16 [in] input string
 * @return converted string
 */
std::string Narrow(std::wstring const& utf16);

// convenience overloads for Widen and Narrow
std::string Narrow(wchar_t const* utf16);
std::string Narrow(char const* notActuallyUtf16);
std::string Narrow(std::string const& notActuallyUtf16);
std::wstring Widen(wchar_t const* notActuallyUtf8);
std::wstring Widen(char const* utf8);
std::wstring Widen(std::wstring const& notActuallyUtf8);

int UnicodeToUTF8(wchar_t const* unicode, char* utf8, size_t utf8len);

int UTF8ToUnicode(char const* utf8, wchar_t* unicode, size_t unicodeLen);

int UnicodeLen(wchar_t const* unicode);

void Append(TCHAR* str1, size_t maxSize, wchar_t const* str2);

void Append(TCHAR* str1, size_t maxSize, char const* str2);

/*
 * Convert from TCHAR to string
 * @param pChar [in] Input TCHAR array
 * @return converted string
 */
std::string TCharToString(TCHAR const* pChar);

}  // namespace utility
}  // namespace gpa