mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
25 lines
351 B
C
25 lines
351 B
C
#include "switch/runtime/util/utf.h"
|
|
|
|
ssize_t
|
|
encode_utf16(uint16_t *out,
|
|
uint32_t in)
|
|
{
|
|
if(in < 0x10000)
|
|
{
|
|
if(out != NULL)
|
|
*out++ = in;
|
|
return 1;
|
|
}
|
|
else if(in < 0x110000)
|
|
{
|
|
if(out != NULL)
|
|
{
|
|
*out++ = (in >> 10) + 0xD7C0;
|
|
*out++ = (in & 0x3FF) + 0xDC00;
|
|
}
|
|
return 2;
|
|
}
|
|
|
|
return -1;
|
|
}
|