Encodes Unicode character code to UTF-8.

Note:

  • This function can be used when you want to encode a Unicode character code to UTF-8 directly in your application.
  • The following functions execute this function internally, so applications that use these functions do not need to call this function.

Syntax

int CONV_UnicodeToUtf8(
  int unicode,
  char **wp
);

Parameters

unicode
[in] Unicode (16 bits)
wp
[in, out] A pointer to a pointer that points a buffer that stores UTF-8 encoded results.

Return value

Returns the number of bytes resulting from encoding.

Remarks

This function encodes the Unicode character code specified by unicode in UTF-8 format, stores the result in the buffer pointed to by the pointer specified by wp and returns its number of bytes. The number of bytes is added to the pointer specified by wp.

Sample

If you specify 0x20AC (€) for unicode and encode to UTF-8, the output will be as follows.
Before encoding:
+0 ← Pointer specified by wp
+1
+2
+3

After encoding:
+0 0xE2
+1 0x82
+2 0xAC
+3 ← Pointer specified by wp

Requirements

Header file:
CodeConversion.h
Library file:
libCodeConversion.a
libSTARTUPOPH5000.a


Last updated: 2021/07/23