Back to index

nux  3.0.0
Public Member Functions
nux::UnicharToAnsicharConvertion Class Reference

#include <NUnicode.h>

List of all members.

Public Member Functions

 UnicharToAnsicharConvertion ()
ANSICHARConvert (const UNICHAR *Source)
 Convert from UNICHAR to ANSICHAR.

Detailed Description

Definition at line 183 of file NUnicode.h.

Constructor & Destructor Documentation

Definition at line 187 of file NUnicode.h.


Member Function Documentation

Convert from UNICHAR to ANSICHAR.

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

Definition at line 30 of file NUnicode.cpp.

    std::wstring utf16string (Source);
    size_t utf16size = utf16string.length();
    size_t utf8size = 6 * utf16size;
    ANSICHAR *utf8string = new ANSICHAR[utf8size+1];

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

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

    if (res != conversionOK)
      delete [] utf8string;
      utf8string = 0;

    // mark end of string
    *target_start = 0;
    return utf8string;

Here is the call graph for this function:

Here is the caller graph for this function:

The documentation for this class was generated from the following files: