muteki
Loading...
Searching...
No Matches
utf16.h File Reference

UTF-16 conversion utilities. More...

#include <muteki/common.h>

Go to the source code of this file.

Typedefs

typedef enum utf16_mb_encoding_e utf16_mb_encoding_e
 Supported encoding types.
 

Enumerations

enum  utf16_mb_encoding_e {
  MB_ENCODING_CP936 = 0x0001 , MB_ENCODING_CP950 = 0x0002 , MB_ENCODING_CP932 = 0x0004 , MB_ENCODING_CP949 = 0x0008 ,
  MB_ENCODING_CP874 = 0x0010 , MB_ENCODING_CP1252 = 0x1000 , MB_ENCODING_UTF8 = 0x7fff , MB_ENCODING_UTF16 = 0x8000 ,
  MB_ENCODING_DEFAULT = 0xffff
}
 Supported encoding types. More...
 

Functions

UTF16 ConvCharToUnicode (unsigned int src, unsigned short src_encoding)
 Convert a multi-byte codepoint to UTF-16.
 
UTF16ConvStrToUnicode (const void *src, UTF16 *dst, unsigned short src_encoding)
 Convert a multi-byte string to UTF-16.
 

Detailed Description

UTF-16 conversion utilities.

Provides utility functions to convert strings of various types of encoding to UTF-16.

Note
The supported encoding types are pretty limited and there might be surprising (or straight-up broken) behavior that goes beyond our control. Use libiconv, ICU, etc. if you want to do more than what is available here.

Enumeration Type Documentation

◆ utf16_mb_encoding_e

Supported encoding types.

Enumerator
MB_ENCODING_CP936 

Use CP936 (GB18030-based).

Supported by both ConvStrToUnicode() and ConvCharToUnicode().

MB_ENCODING_CP950 

Use CP950 (BIG5-based).

Supported by both ConvStrToUnicode() and ConvCharToUnicode().

MB_ENCODING_CP932 

Use CP932 (Shift-JIS-based).

Supported by both ConvStrToUnicode() and ConvCharToUnicode().

MB_ENCODING_CP949 

Use CP949 (EUC-KR-based).

Supported by both ConvStrToUnicode() and ConvCharToUnicode().

MB_ENCODING_CP874 

Use CP874 (TIS-620-based).

Supported by ConvStrToUnicode() only.

MB_ENCODING_CP1252 

Use CP1252 (ISO8859-1-based).

Supported by ConvStrToUnicode() only.

Warning
This may not work as intended, as it is an alias to CP950 on at least BA742.
MB_ENCODING_UTF8 

Use UTF-8.

Supported by ConvStrToUnicode() only.

MB_ENCODING_UTF16 

Use UTF-16.

Supported by both ConvStrToUnicode() and ConvCharToUnicode().

MB_ENCODING_DEFAULT 

Use default encoding.

On BA742 this is hardcoded to be CP936.

Supported by both ConvStrToUnicode() and ConvCharToUnicode().

Function Documentation

◆ ConvCharToUnicode()

UTF16 ConvCharToUnicode ( unsigned int  src,
unsigned short  src_encoding 
)
extern

Convert a multi-byte codepoint to UTF-16.

Note
Not all encoding types listed in utf16_mb_encoding_e are supported by this syscall. Check the documentation of it before proceeding. Passing unsupported encoding type to this syscall will cause undefined behavior.
Syscall Number
0x100bc
Parameters
srcMulti-byte codepoint.
src_encodingEncoding type of the input codepoint.
Returns
UTF-16 codepoint.
See also
utf16_mb_encoding_e Supported encoding types.

◆ ConvStrToUnicode()

UTF16 * ConvStrToUnicode ( const void *  src,
UTF16 dst,
unsigned short  src_encoding 
)
extern

Convert a multi-byte string to UTF-16.

Note
Passing unsupported encoding type to this syscall will cause undefined behavior.
Syscall Number
0x100bd
Parameters
[in]srcSource multi-byte string.
[out]dstConverted UTF-16 string.
src_encodingEncoding type of the input codepoint.
Returns
Converted UTF-16 string.
See also
utf16_mb_encoding_e Supported encoding types.