3ds Max C++ API Reference
maxchar.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include "maxheap.h"
#include "strbasic.h"

Classes

class  Char
 Represents a single Unicode character. More...
 
class  CharIterator< ChType >
 Iterate intelligently inside a string. More...
 
class  CharAccumulator
 Character accumulator. More...
 

Namespaces

 MaxSDK
 
 MaxSDK::Util
 

Functions

UtilExport size_t UTF32ToWideChar (const unsigned int *lpUTF32CharStr, size_t ccUTF32Char, wchar_t *lpWideCharStr, size_t cchWideChar)
 Convert a UTF32 character string to UTF16 characters. More...
 
UtilExport size_t WideCharToUTF32 (const wchar_t *lpWideCharStr, size_t cchWideChar, unsigned int *lpUTF32CharStr, size_t ccUTF32Char)
 Convert UTF16 character string to UTF32 characters. More...
 

Function Documentation

◆ UTF32ToWideChar()

UtilExport size_t UTF32ToWideChar ( const unsigned int lpUTF32CharStr,
size_t  ccUTF32Char,
wchar_t *  lpWideCharStr,
size_t  cchWideChar 
)

Convert a UTF32 character string to UTF16 characters.

Parameters
lpUTF32CharStrPointer to the character string to convert.
ccUTF32CharSize, in WWCHAR, of the string indicated by the lpUTF32CharStr parameter. Alternatively, this parameter can be set to -1 if the string is null-terminated. Note that, if ccUTF32Char is 0, the function fails.

If this parameter is -1, the function processes the entire input string, including the terminating null character. Therefore, the resulting Unicode string has a terminating null character, and the length returned by the function includes this character.

If this parameter is set to a positive integer, the function processes exactly the specified number of bytes. If the provided size does not include a terminating null character, the resulting Unicode string is not null-terminated, and the returned length does not include this character.

Parameters
lpWideCharStrOptional. Pointer to a buffer that receives the converted string.
cchWideCharSize, in WCHAR, of the buffer indicated by lpWideCharStr. If this value is 0, the function returns the required buffer size, in characters, including any terminating null character, and makes no use of the lpWideCharStr buffer.
Returns
Returns the number of characters written to the buffer indicated by lpWideCharStr if successful. If the function succeeds and cchWideChar is 0, the return value is the required size, in WCHAR, for the buffer indicated by lpWideCharStr.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

◆ WideCharToUTF32()

UtilExport size_t WideCharToUTF32 ( const wchar_t *  lpWideCharStr,
size_t  cchWideChar,
unsigned int lpUTF32CharStr,
size_t  ccUTF32Char 
)

Convert UTF16 character string to UTF32 characters.

Parameters
lpWideCharStrPointer to the character string to convert.
cchWideCharSize, in WCHAR, of the string indicated by the lpWideCharStr parameter. Alternatively, this parameter can be set to -1 if the string is null-terminated. Note that, if cchWideChar is 0, the function fails.

If this parameter is -1, the function processes the entire input string, including the terminating null character. Therefore, the resulting Unicode string has a terminating null character, and the length returned by the function includes this character.

If this parameter is set to a positive integer, the function processes exactly the specified number of bytes. If the provided size does not include a terminating null character, the resulting Unicode string is not null-terminated, and the returned length does not include this character.

Parameters
lpUTF32CharStrOptional. Pointer to a buffer that receives the converted string.
ccUTF32CharSize, in WWCHAR, of the buffer indicated by lpUTF32CharStr. If this value is 0, the function returns the required buffer size, in characters, including any terminating null character, and makes no use of the lpUTF32CharStr buffer.
Returns
Returns the number of character written to the buffer indicated by lpUTF32CharStr if successful. If the function succeeds and ccUTF32Char is 0, the return value is the required size, in WWCHAR, for the buffer indicated by lpUTF32CharStr.

The function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.