Add libs so they don't have to be generated
This commit is contained in:
parent
838f849df8
commit
a5ae425318
127 changed files with 10687 additions and 0 deletions
157
src/libnx/nx/include/switch/runtime/util/utf.h
Normal file
157
src/libnx/nx/include/switch/runtime/util/utf.h
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/**
|
||||
* @file utf.h
|
||||
* @brief UTF conversion functions.
|
||||
* @author mtheall
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include <sys/types.h>
|
||||
#include "../../types.h"
|
||||
|
||||
/** Convert a UTF-8 sequence into a UTF-32 codepoint
|
||||
*
|
||||
* @param[out] out Output codepoint
|
||||
* @param[in] in Input sequence
|
||||
*
|
||||
* @returns number of input code units consumed
|
||||
* @returns -1 for error
|
||||
*/
|
||||
ssize_t decode_utf8 (uint32_t *out, const uint8_t *in);
|
||||
|
||||
/** Convert a UTF-16 sequence into a UTF-32 codepoint
|
||||
*
|
||||
* @param[out] out Output codepoint
|
||||
* @param[in] in Input sequence
|
||||
*
|
||||
* @returns number of input code units consumed
|
||||
* @returns -1 for error
|
||||
*/
|
||||
ssize_t decode_utf16(uint32_t *out, const uint16_t *in);
|
||||
|
||||
/** Convert a UTF-32 codepoint into a UTF-8 sequence
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input codepoint
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out must be able to store 4 code units
|
||||
*/
|
||||
ssize_t encode_utf8 (uint8_t *out, uint32_t in);
|
||||
|
||||
/** Convert a UTF-32 codepoint into a UTF-16 sequence
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input codepoint
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out must be able to store 2 code units
|
||||
*/
|
||||
ssize_t encode_utf16(uint16_t *out, uint32_t in);
|
||||
|
||||
/** Convert a UTF-8 sequence into a UTF-16 sequence
|
||||
*
|
||||
* Fills the output buffer up to \a len code units.
|
||||
* Returns the number of code units that the input would produce;
|
||||
* if it returns greater than \a len, the output has been
|
||||
* truncated.
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input sequence (null-terminated)
|
||||
* @param[in] len Output length
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out is not null-terminated
|
||||
*/
|
||||
ssize_t utf8_to_utf16(uint16_t *out, const uint8_t *in, size_t len);
|
||||
|
||||
/** Convert a UTF-8 sequence into a UTF-32 sequence
|
||||
*
|
||||
* Fills the output buffer up to \a len code units.
|
||||
* Returns the number of code units that the input would produce;
|
||||
* if it returns greater than \a len, the output has been
|
||||
* truncated.
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input sequence (null-terminated)
|
||||
* @param[in] len Output length
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out is not null-terminated
|
||||
*/
|
||||
ssize_t utf8_to_utf32(uint32_t *out, const uint8_t *in, size_t len);
|
||||
|
||||
/** Convert a UTF-16 sequence into a UTF-8 sequence
|
||||
*
|
||||
* Fills the output buffer up to \a len code units.
|
||||
* Returns the number of code units that the input would produce;
|
||||
* if it returns greater than \a len, the output has been
|
||||
* truncated.
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input sequence (null-terminated)
|
||||
* @param[in] len Output length
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out is not null-terminated
|
||||
*/
|
||||
ssize_t utf16_to_utf8(uint8_t *out, const uint16_t *in, size_t len);
|
||||
|
||||
/** Convert a UTF-16 sequence into a UTF-32 sequence
|
||||
*
|
||||
* Fills the output buffer up to \a len code units.
|
||||
* Returns the number of code units that the input would produce;
|
||||
* if it returns greater than \a len, the output has been
|
||||
* truncated.
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input sequence (null-terminated)
|
||||
* @param[in] len Output length
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out is not null-terminated
|
||||
*/
|
||||
ssize_t utf16_to_utf32(uint32_t *out, const uint16_t *in, size_t len);
|
||||
|
||||
/** Convert a UTF-32 sequence into a UTF-8 sequence
|
||||
*
|
||||
* Fills the output buffer up to \a len code units.
|
||||
* Returns the number of code units that the input would produce;
|
||||
* if it returns greater than \a len, the output has been
|
||||
* truncated.
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input sequence (null-terminated)
|
||||
* @param[in] len Output length
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out is not null-terminated
|
||||
*/
|
||||
ssize_t utf32_to_utf8(uint8_t *out, const uint32_t *in, size_t len);
|
||||
|
||||
/** Convert a UTF-32 sequence into a UTF-16 sequence
|
||||
*
|
||||
* @param[out] out Output sequence
|
||||
* @param[in] in Input sequence (null-terminated)
|
||||
* @param[in] len Output length
|
||||
*
|
||||
* @returns number of output code units produced
|
||||
* @returns -1 for error
|
||||
*
|
||||
* @note \a out is not null-terminated
|
||||
*/
|
||||
ssize_t utf32_to_utf16(uint16_t *out, const uint32_t *in, size_t len);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue