2024-04-25 10:38:13 +08:00
# pragma once
# include "YYCCInternal.hpp"
2024-04-26 15:37:28 +08:00
# include <string>
2024-06-18 11:03:48 +08:00
# if YYCC_OS == YYCC_OS_WINDOWS
2024-04-25 10:38:13 +08:00
# include "WinImportPrefix.hpp"
# include <Windows.h>
# include "WinImportSuffix.hpp"
2024-06-18 11:03:48 +08:00
# endif
2024-04-25 10:38:13 +08:00
2024-06-18 16:03:41 +08:00
/**
2024-07-05 22:25:14 +08:00
* @ brief The helper for all encoding aspects .
2024-06-18 16:03:41 +08:00
* @ details
2024-07-05 22:25:14 +08:00
* For more infomations about how to use the functions provided by this namespace ,
* please see \ ref library_encoding and \ ref encoding_helper .
2024-06-18 16:03:41 +08:00
*/
2024-04-25 10:38:13 +08:00
namespace YYCC : : EncodingHelper {
2024-07-05 22:25:14 +08:00
# define _YYCC_U8(strl) u8 ## strl ///< The assistant macro for YYCC_U8.
# define YYCC_U8(strl) (reinterpret_cast<const ::YYCC::yycc_char8_t*>(_YYCC_U8(strl))) ///< The macro for creating UTF8 string literal. See \ref library_encoding.
2024-07-13 12:58:49 +08:00
# define YYCC_U8_CHAR(chr) (static_cast<YYCC::yycc_char8_t>(chr)) ///< The macro for casting normal char into YYCC UTF8 char type.
2024-06-27 20:49:02 +08:00
const yycc_char8_t * ToUTF8 ( const char * src ) ;
yycc_char8_t * ToUTF8 ( char * src ) ;
yycc_u8string ToUTF8 ( const std : : string_view & src ) ;
yycc_u8string_view ToUTF8View ( const std : : string_view & src ) ;
2024-07-05 10:36:24 +08:00
const char * ToOrdinary ( const yycc_char8_t * src ) ;
char * ToOrdinary ( yycc_char8_t * src ) ;
std : : string ToOrdinary ( const yycc_u8string_view & src ) ;
std : : string_view ToOrdinaryView ( const yycc_u8string_view & src ) ;
2024-06-27 20:49:02 +08:00
2024-06-18 11:03:48 +08:00
# if YYCC_OS == YYCC_OS_WINDOWS
2024-06-27 20:49:02 +08:00
bool WcharToChar ( const std : : wstring_view & src , std : : string & dst , UINT code_page ) ;
2024-06-26 21:04:56 +08:00
bool WcharToChar ( const wchar_t * src , std : : string & dst , UINT code_page ) ;
2024-06-27 20:49:02 +08:00
std : : string WcharToChar ( const std : : wstring_view & src , UINT code_page ) ;
2024-06-26 21:04:56 +08:00
std : : string WcharToChar ( const wchar_t * src , UINT code_page ) ;
2024-05-20 21:41:48 +08:00
2024-06-27 20:49:02 +08:00
bool CharToWchar ( const std : : string_view & src , std : : wstring & dst , UINT code_page ) ;
2024-06-26 21:04:56 +08:00
bool CharToWchar ( const char * src , std : : wstring & dst , UINT code_page ) ;
2024-06-27 20:49:02 +08:00
std : : wstring CharToWchar ( const std : : string_view & src , UINT code_page ) ;
2024-06-26 21:04:56 +08:00
std : : wstring CharToWchar ( const char * src , UINT code_page ) ;
2024-05-20 21:41:48 +08:00
2024-06-27 20:49:02 +08:00
bool CharToChar ( const std : : string_view & src , std : : string & dst , UINT src_code_page , UINT dst_code_page ) ;
2024-06-26 21:04:56 +08:00
bool CharToChar ( const char * src , std : : string & dst , UINT src_code_page , UINT dst_code_page ) ;
2024-06-27 20:49:02 +08:00
std : : string CharToChar ( const std : : string_view & src , UINT src_code_page , UINT dst_code_page ) ;
2024-06-26 21:04:56 +08:00
std : : string CharToChar ( const char * src , UINT src_code_page , UINT dst_code_page ) ;
2024-06-27 20:49:02 +08:00
bool WcharToUTF8 ( const std : : wstring_view & src , yycc_u8string & dst ) ;
2024-06-26 21:04:56 +08:00
bool WcharToUTF8 ( const wchar_t * src , yycc_u8string & dst ) ;
2024-06-27 20:49:02 +08:00
yycc_u8string WcharToUTF8 ( const std : : wstring_view & src ) ;
2024-06-26 21:04:56 +08:00
yycc_u8string WcharToUTF8 ( const wchar_t * src ) ;
2024-06-27 20:49:02 +08:00
bool UTF8ToWchar ( const yycc_u8string_view & src , std : : wstring & dst ) ;
2024-06-26 21:04:56 +08:00
bool UTF8ToWchar ( const yycc_char8_t * src , std : : wstring & dst ) ;
2024-06-27 20:49:02 +08:00
std : : wstring UTF8ToWchar ( const yycc_u8string_view & src ) ;
2024-06-26 21:04:56 +08:00
std : : wstring UTF8ToWchar ( const yycc_char8_t * src ) ;
2024-07-09 21:02:26 +08:00
bool CharToUTF8 ( const std : : string_view & src , yycc_u8string & dst , UINT code_page ) ;
bool CharToUTF8 ( const char * src , yycc_u8string & dst , UINT code_page ) ;
yycc_u8string CharToUTF8 ( const std : : string_view & src , UINT code_page ) ;
yycc_u8string CharToUTF8 ( const char * src , UINT code_page ) ;
bool UTF8ToChar ( const yycc_u8string_view & src , std : : string & dst , UINT code_page ) ;
bool UTF8ToChar ( const yycc_char8_t * src , std : : string & dst , UINT code_page ) ;
std : : string UTF8ToChar ( const yycc_u8string_view & src , UINT code_page ) ;
std : : string UTF8ToChar ( const yycc_char8_t * src , UINT code_page ) ;
2024-04-25 10:38:13 +08:00
2024-06-18 11:03:48 +08:00
# endif
2024-06-27 20:49:02 +08:00
bool UTF8ToUTF16 ( const yycc_u8string_view & src , std : : u16string & dst ) ;
2024-06-26 21:04:56 +08:00
bool UTF8ToUTF16 ( const yycc_char8_t * src , std : : u16string & dst ) ;
2024-06-27 20:49:02 +08:00
std : : u16string UTF8ToUTF16 ( const yycc_u8string_view & src ) ;
2024-06-26 21:04:56 +08:00
std : : u16string UTF8ToUTF16 ( const yycc_char8_t * src ) ;
2024-06-27 20:49:02 +08:00
bool UTF16ToUTF8 ( const std : : u16string_view & src , yycc_u8string & dst ) ;
2024-06-26 21:04:56 +08:00
bool UTF16ToUTF8 ( const char16_t * src , yycc_u8string & dst ) ;
2024-06-27 20:49:02 +08:00
yycc_u8string UTF16ToUTF8 ( const std : : u16string_view & src ) ;
2024-06-26 21:04:56 +08:00
yycc_u8string UTF16ToUTF8 ( const char16_t * src ) ;
2024-06-27 20:49:02 +08:00
bool UTF8ToUTF32 ( const yycc_u8string_view & src , std : : u32string & dst ) ;
2024-06-26 21:04:56 +08:00
bool UTF8ToUTF32 ( const yycc_char8_t * src , std : : u32string & dst ) ;
2024-06-27 20:49:02 +08:00
std : : u32string UTF8ToUTF32 ( const yycc_u8string_view & src ) ;
2024-06-26 21:04:56 +08:00
std : : u32string UTF8ToUTF32 ( const yycc_char8_t * src ) ;
2024-04-26 15:37:28 +08:00
2024-06-27 20:49:02 +08:00
bool UTF32ToUTF8 ( const std : : u32string_view & src , yycc_u8string & dst ) ;
2024-06-26 21:04:56 +08:00
bool UTF32ToUTF8 ( const char32_t * src , yycc_u8string & dst ) ;
2024-06-27 20:49:02 +08:00
yycc_u8string UTF32ToUTF8 ( const std : : u32string_view & src ) ;
2024-06-26 21:04:56 +08:00
yycc_u8string UTF32ToUTF8 ( const char32_t * src ) ;
2024-06-18 11:03:48 +08:00
}