nux-1.14.0
nux::AnsicharToUnicharConvertion Class Reference

ANSICHAR to UNICHAR conversion. More...

#include <NuxCore/Character/NUnicode.h>

List of all members.

Public Member Functions

UNICHAR * Convert (const ANSICHAR *Source)

Detailed Description

ANSICHAR to UNICHAR conversion.

Definition at line 219 of file NUnicode.h.


Member Function Documentation

UNICHAR * nux::AnsicharToUnicharConvertion::Convert ( const ANSICHAR *  Source)

Convert from ANSICHAR to UNICHAR

Parameters:
SourceString to convert. Null terminated.
Returns:
Return a pointer to the new string. Null terminated.

Definition at line 55 of file NUnicode.cpp.

Referenced by nux::AnsiToTCharConversion::Convert(), and nux::TCharToUnicharConvertion::Convert().

  {
    std::string utf8string (Source);
    size_t utf8size = utf8string.length();
    size_t utf16size = utf8size;
    UNICHAR *utf16string = new UNICHAR[utf16size+1];

    const t_UTF8 *source_start = reinterpret_cast<const t_UTF8 *> (utf8string.c_str() );
    const t_UTF8 *source_end = source_start + utf8size;
    t_UTF16 *target_start = reinterpret_cast<t_UTF16 *> (utf16string);
    t_UTF16 *target_end = target_start + utf16size;

    ConversionResult res = ConvertUTF8toUTF16 (&source_start, source_end, &target_start, target_end, lenientConversion);

    if (res != conversionOK)
    {
      delete[] utf16string;
      utf16string = 0;
    }

    // mark end of string
    *target_start = 0;
    return utf16string;
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends