logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_UCS4ToUTF8 - Convert a single Unicode codepoint to UTF-8.

Availability

       This function is available since SDL 3.2.0.

Simple Directmedia Layer                           SDL 3.2.20                                  SDL_UCS4ToUTF8(3)

Description

       The buffer pointed to by dst must be at least 4 bytes long, as this function may generate between 1 and 4
       bytes of output.

       This  function  returns  the  first  byte  _after_  the newly-written UTF-8 sequence, which is useful for
       encoding multiple codepoints in a loop, or knowing where to write a NULL-terminator character to end  the
       string (in either case, plan to have a buffer of _more_ than 4 bytes!).

       If codepoint is an invalid value (outside the Unicode range, or a UTF-16 surrogate value, etc), this will
       use U+FFFD (REPLACEMENT CHARACTER) for the codepoint instead, and not set an error.

       If  dst  is  NULL,  this  returns  NULL immediately without writing to the pointer and without setting an
       error.

Function Parameters

codepoint
              a Unicode codepoint to convert to UTF-8.

       dst    the location to write the encoded UTF-8. Must point to at least 4 bytes!

Name

       SDL_UCS4ToUTF8 - Convert a single Unicode codepoint to UTF-8.

Return Value

       Returns the first byte past the newly-written UTF-8 sequence.

Synopsis

#include<SDL3/SDL_stdinc.h>char*SDL_UCS4ToUTF8(Uint32codepoint,char*dst);

Thread Safety

       It is safe to call this function from any thread.

See Also