2025-09-30 16:48:13 +01:00
|
|
|
|
// Copyright (c) 2014-2018 Zano Project
|
|
|
|
|
|
// Copyright (c) 2014-2018 The Louisdor Project
|
|
|
|
|
|
// Copyright (c) 2012-2013 The Boolberry developers
|
|
|
|
|
|
// Copyright (c) 2017-2025 Lethean (https://lt.hn)
|
|
|
|
|
|
//
|
|
|
|
|
|
// Licensed under the European Union Public Licence (EUPL) version 1.2.
|
|
|
|
|
|
// You may obtain a copy of the licence at:
|
|
|
|
|
|
//
|
|
|
|
|
|
// https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
|
|
|
|
|
|
//
|
|
|
|
|
|
// The EUPL is a copyleft licence that is compatible with the MIT/X11
|
|
|
|
|
|
// licence used by the original projects; the MIT terms are therefore
|
|
|
|
|
|
// considered “grandfathered” under the EUPL for this code.
|
|
|
|
|
|
//
|
|
|
|
|
|
// SPDX‑License‑Identifier: EUPL-1.2
|
|
|
|
|
|
//
|
2025-03-14 19:15:54 +04:00
|
|
|
|
|
|
|
|
|
|
#ifndef UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
|
|
|
|
|
|
#define UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
|
|
|
|
|
|
|
|
|
|
|
|
#include "checked.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace utf8
|
|
|
|
|
|
{
|
|
|
|
|
|
inline void append16(utfchar32_t cp, std::u16string& s)
|
|
|
|
|
|
{
|
|
|
|
|
|
append16(cp, std::back_inserter(s));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline std::string utf16to8(const std::u16string& s)
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string result;
|
|
|
|
|
|
utf16to8(s.begin(), s.end(), std::back_inserter(result));
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline std::u16string utf8to16(const std::string& s)
|
|
|
|
|
|
{
|
|
|
|
|
|
std::u16string result;
|
|
|
|
|
|
utf8to16(s.begin(), s.end(), std::back_inserter(result));
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline std::string utf32to8(const std::u32string& s)
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string result;
|
|
|
|
|
|
utf32to8(s.begin(), s.end(), std::back_inserter(result));
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline std::u32string utf8to32(const std::string& s)
|
|
|
|
|
|
{
|
|
|
|
|
|
std::u32string result;
|
|
|
|
|
|
utf8to32(s.begin(), s.end(), std::back_inserter(result));
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
} // namespace utf8
|
|
|
|
|
|
|
|
|
|
|
|
#endif // header guard
|
|
|
|
|
|
|