mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-03 16:59:04 +00:00
Move dependencies to the top level.
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @file TranscodeUtil.h
|
||||
* @brief Declaration of tc::string::TranscodeUtil
|
||||
* @author Jack (jakcron)
|
||||
* @version 0.2
|
||||
* @date 2020/03/22
|
||||
**/
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include <tc/ArgumentException.h>
|
||||
|
||||
namespace tc { namespace string {
|
||||
|
||||
/**
|
||||
* @class TranscodeUtil
|
||||
* @brief Collection of functions to transcode between UTF-8/UTF-16/UTF-32
|
||||
**/
|
||||
class TranscodeUtil
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Transcode a UTF-8 string to UTF-32.
|
||||
* @param[in] src Source UTF-8 string.
|
||||
* @param[out] dst Destination UTF-32 string.
|
||||
*
|
||||
* @throw tc::ArgumentException When src is an invalid string.
|
||||
**/
|
||||
static void UTF8ToUTF32(const std::string& src, std::u32string& dst);
|
||||
|
||||
/**
|
||||
* @brief Transcode a UTF-16 string to UTF-32.
|
||||
* @param[in] src Source UTF-16 string.
|
||||
* @param[out] dst Destination UTF-32 string.
|
||||
*
|
||||
* @throw tc::ArgumentException When src is an invalid string.
|
||||
**/
|
||||
static void UTF16ToUTF32(const std::u16string& src, std::u32string& dst);
|
||||
|
||||
/**
|
||||
* @brief Transcode a UTF-32 string to UTF-8.
|
||||
* @param[in] src Source UTF-32 string.
|
||||
* @param[out] dst Destination UTF-8 string.
|
||||
*
|
||||
* @throw tc::ArgumentException When src is an invalid string.
|
||||
**/
|
||||
static void UTF32ToUTF8(const std::u32string& src, std::string& dst);
|
||||
|
||||
/**
|
||||
* @brief Transcode a UTF-32 string to UTF-16.
|
||||
* @param[in] src Source UTF-32 string.
|
||||
* @param[out] dst Destination UTF-16 string.
|
||||
*
|
||||
* @throw tc::ArgumentException When src is an invalid string.
|
||||
**/
|
||||
static void UTF32ToUTF16(const std::u32string& src, std::u16string& dst);
|
||||
|
||||
/**
|
||||
* @brief Transcode a UTF-8 string to UTF-16.
|
||||
* @param[in] src Source UTF-8 string.
|
||||
* @param[out] dst Destination UTF-16 string.
|
||||
*
|
||||
* @throw tc::ArgumentException When src is an invalid string.
|
||||
**/
|
||||
static void UTF8ToUTF16(const std::string& src, std::u16string& dst);
|
||||
|
||||
/**
|
||||
* @brief Transcode a UTF-16 string to UTF-8.
|
||||
* @param[in] src Source UTF-16 string.
|
||||
* @param[out] dst Destination UTF-8 string.
|
||||
*
|
||||
* @throw tc::ArgumentException When src is an invalid string.
|
||||
**/
|
||||
static void UTF16ToUTF8(const std::u16string& src, std::string& dst);
|
||||
};
|
||||
|
||||
}} // namespace tc::string
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* @file utf16.h
|
||||
* @brief Declaration of UTF-16 constants and macros
|
||||
* @author Jack (jakcron)
|
||||
* @version 0.1
|
||||
* @date 2019/01/15
|
||||
*/
|
||||
#pragma once
|
||||
#include <tc/types.h>
|
||||
|
||||
namespace tc { namespace string { namespace detail {
|
||||
|
||||
static const char32_t kUtf16EncodeMax = 0x10FFFF;
|
||||
static const char32_t kUtf16NonNativeStart = 0x10000;
|
||||
static const char16_t kUtf16SurrogateBits = 10;
|
||||
static const char16_t kUtf16SurrogateMask = (1 << kUtf16SurrogateBits) - 1;
|
||||
static const char16_t kUtf16HighSurrogateStart = 0xD800;
|
||||
static const char16_t kUtf16HighSurrogateEnd = kUtf16HighSurrogateStart | kUtf16SurrogateMask;
|
||||
static const char16_t kUtf16LowSurrogateStart = 0xDC00;
|
||||
static const char16_t kUtf16LowSurrogateEnd = kUtf16LowSurrogateStart | kUtf16SurrogateMask;
|
||||
|
||||
}}} // namespace tc::string::detail
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
/**
|
||||
* @file utf8.h
|
||||
* @brief Declaration of UTF-8 constants and macros
|
||||
* @author Jack (jakcron)
|
||||
* @version 0.2
|
||||
* @date 2021/01/26
|
||||
*/
|
||||
#pragma once
|
||||
#include <tc/types.h>
|
||||
|
||||
namespace tc { namespace string { namespace detail {
|
||||
|
||||
static const char32_t kUtf8AsciiStart = 0x00;
|
||||
static const char32_t kUtf8AsciiEnd = 0x7F;
|
||||
static const char32_t kUtf82ByteStart = 0x80;
|
||||
static const char32_t kUtf82ByteEnd = 0x7FF;
|
||||
static const char32_t kUtf83ByteStart = 0x800;
|
||||
static const char32_t kUtf83ByteEnd = 0x7FFF;
|
||||
static const char32_t kUtf84ByteStart = 0x8000;
|
||||
static const char32_t kUtf84ByteEnd = 0x10FFFF;
|
||||
|
||||
static inline uint8_t make_utf8_prefix(uint8_t prefix_bits) { return ((uint8_t)(-1)) << (8 - prefix_bits); }
|
||||
static inline uint8_t make_utf8_mask(uint8_t prefix_bits) { return ((uint8_t)(-1)) >> (prefix_bits + 1); }
|
||||
static inline uint8_t make_utf8(uint8_t prefix_bits, uint8_t data) { return make_utf8_prefix(prefix_bits) | (data & make_utf8_mask(prefix_bits)); }
|
||||
static inline uint8_t get_utf8_data(uint8_t prefix_bits, uint8_t utf8_chr) { return utf8_chr & make_utf8_mask(prefix_bits); }
|
||||
static inline bool utf8_has_prefix(uint8_t prefix_bits, uint8_t utf8_chr) { return ((utf8_chr & make_utf8_prefix(prefix_bits)) == make_utf8_prefix(prefix_bits)) && ((utf8_chr & ~make_utf8_mask(prefix_bits)) == make_utf8_prefix(prefix_bits)); }
|
||||
static inline uint8_t get_utf8_prefix(uint8_t utf8_chr)
|
||||
{
|
||||
uint8_t prefix = 0;
|
||||
while ((utf8_chr & (1 << 7)) != 0)
|
||||
{
|
||||
utf8_chr <<= 1;
|
||||
prefix++;
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
}}} // namespace tc::string::detail
|
||||
Reference in New Issue
Block a user