| e8555c89 Andy McCall |
1 |
#ifndef MSXCHAR2UNICODE_HH |
| 2 |
#define MSXCHAR2UNICODE_HH |
| 3 |
|
| 4 |
#include <array> |
| 5 |
#include <cstdint> |
| 6 |
#include <functional> |
| 7 |
#include <span> |
| 8 |
#include <string> |
| 9 |
#include <string_view> |
| 10 |
#include <vector> |
| 11 |
|
| 12 |
namespace openmsx { |
| 13 |
|
| 14 |
class MsxChar2Unicode |
| 15 |
{ |
| 16 |
public: |
| 17 |
explicit MsxChar2Unicode(std::string_view mappingName); |
| 18 |
|
| 19 |
|
| 20 |
[[nodiscard]] std::string msxToUtf8( |
| 21 |
std::span<const uint8_t> msx, |
| 22 |
const std::function<uint32_t(uint8_t)>& fallback) const; |
| 23 |
|
| 24 |
[[nodiscard]] std::vector<uint8_t> utf8ToMsx( |
| 25 |
std::string_view utf8, |
| 26 |
const std::function<uint8_t(uint32_t)>& fallback) const; |
| 27 |
|
| 28 |
[[nodiscard]] std::string msxToUtf8(std::span<const uint8_t> msx, char fallback) const; |
| 29 |
[[nodiscard]] std::vector<uint8_t> utf8ToMsx(std::string_view utf8, char fallback) const; |
| 30 |
|
| 31 |
private: |
| 32 |
void parseVid(std::string_view file); |
| 33 |
|
| 34 |
private: |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
std::array<uint32_t, 256> msx2unicode; |
| 39 |
|
| 40 |
|
| 41 |
struct Entry { |
| 42 |
Entry(uint32_t u, uint8_t m) : unicode(u), msx(m) {} |
| 43 |
uint32_t unicode; |
| 44 |
uint8_t msx; |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
std::vector<Entry> unicode2msx; |
| 49 |
}; |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
#endif |