60 lines
2.4 KiB
C++
60 lines
2.4 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: Locale.hpp
|
|
Date: 2021-6-11
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#define I_REALLY_NEED_WIDECHAR_PUBAPI
|
|
|
|
#if defined (VENDOR_GENERIC_MICROSOFT) || defined(VENDOR_CONSOLE_MICROSOFT)
|
|
// https://docs.microsoft.com/en-us/gaming/gdk/_content/gc/system/overviews/localization/supported_nls_apis
|
|
#define AU_HAS_MSFT_NATIONALLANGSUPPORT
|
|
// https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
|
|
#define CP_LATIN_1 1252
|
|
#define CP_UTF_16 1200
|
|
#define CP_CHINESE 54936
|
|
#define CP_SHIFTJIS 932
|
|
// Ehhhh
|
|
// https://en.wikipedia.org/wiki/Code_page_936_(Microsoft_Windows);
|
|
// https://en.wikipedia.org/wiki/GBK_(character_encoding)
|
|
// `Since its initial release in 1993, GBK has been extended by Microsoft in Code page 936/1386, which was then extended into GBK 1.0`
|
|
#define CP_2312_LIMITED_GBK 936
|
|
#endif
|
|
|
|
#include "Encoding/EncoderAdapter.hpp"
|
|
|
|
namespace Aurora::Locale
|
|
{
|
|
void Init();
|
|
|
|
ECodePage GetInternalCodePage();
|
|
AuString const &GetInternalCodePageString();
|
|
|
|
|
|
|
|
/// bool TranslateNativeStringBuffer(EncodedTextStream &stream, AuString &str);
|
|
|
|
/// Translates a UTF-8 string to something the system codepage won't complain about
|
|
/// size should be at least utf8.size() * 4 for eUTF32 systems
|
|
/// AuUInt EncodeStringToSysCP(const AuString &utf8, AuUInt8 *encoded, AuUInt size);
|
|
|
|
/// Self-explanatory
|
|
/// returns the amount of bytes written
|
|
/// AuUInt EncodeStringToCP(const AuString &utf8, ECodePage page, AuUInt8 *encoded, AuUInt size);
|
|
|
|
/// Alternative TranslateNativeStringBuffer without slow AuString allocations
|
|
/// returns the amount of bytes written
|
|
/// AuUInt TranslateNativeStringBuffer(EncodedTextStream &stream, void *out, AuUInt len, ECodePage guess = ECodePage::eNotRead);
|
|
|
|
/// Once again, this is another slow API for decoding a buffer back to memory
|
|
/// For additional endianness optimization hackery, the read pointer _must_ be writable
|
|
/// The odds are you don't care if the original buffer gets mangled during decode; so
|
|
/// lets swap the endian inside caller provided memory to save on allocation time
|
|
/// bool DecodeStringToUTF8(AuUInt8 *readWriteHead, int length, AuString &decoded, ECodePage guess = ECodePage::eNotRead);
|
|
}
|
|
|
|
#include "Encoding/Encoding.hpp"
|