feat: add encoding convertion functions between utf8 and utf16, utf32.
- add bidirectional convertion between utf8 and utf16, utf32 in every platforms. - add testbench for new added functions.
This commit is contained in:
@ -1,15 +1,18 @@
|
||||
#pragma once
|
||||
#include "YYCCInternal.hpp"
|
||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||
|
||||
#include <string>
|
||||
|
||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||
#include "WinImportPrefix.hpp"
|
||||
#include <Windows.h>
|
||||
#include "WinImportSuffix.hpp"
|
||||
#endif
|
||||
|
||||
namespace YYCC::EncodingHelper {
|
||||
|
||||
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||
|
||||
bool WcharToChar(const wchar_t* src, std::string& dest, UINT codepage);
|
||||
bool WcharToUTF8(const wchar_t* src, std::string& dest);
|
||||
std::string WcharToChar(const wchar_t* src, UINT codepage);
|
||||
@ -23,6 +26,16 @@ namespace YYCC::EncodingHelper {
|
||||
bool CharToChar(const char* src, std::string& dest, UINT src_codepage, UINT dest_codepage);
|
||||
std::string CharToChar(const char* src, UINT src_codepage, UINT dest_codepage);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
bool UTF8ToUTF16(const char* src, std::u16string& dest);
|
||||
std::u16string UTF8ToUTF16(const char* src);
|
||||
bool UTF8ToUTF32(const char* src, std::u32string& dest);
|
||||
std::u32string UTF8ToUTF32(const char* src);
|
||||
|
||||
bool UTF16ToUTF8(const char16_t* src, std::string& dest);
|
||||
std::string UTF16ToUTF8(const char16_t* src);
|
||||
bool UTF32ToUTF8(const char32_t* src, std::string& dest);
|
||||
std::string UTF32ToUTF8(const char32_t* src);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user