openMSX
MsxChar2Unicode.hh
Go to the documentation of this file.
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
12namespace openmsx {
13
15{
16public:
17 explicit MsxChar2Unicode(std::string_view mappingName);
18
20 [[nodiscard]] std::string msxToUtf8(
21 std::span<const uint8_t> msx,
22 const std::function<uint32_t(uint8_t)>& fallback) const;
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
31private:
32 void parseVid(std::string_view file);
33
34private:
35 // LUT: msx graphical character code (as stored in VRAM) -> unicode character
36 // Some entries are not filled in (are invalid), they contain the value -1.
37 // There may be different (valid) entries that contain the same value.
38 std::array<uint32_t, 256> msx2unicode;
39
40 // Reverse LUT: unicode character -> msx graphical character
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 // Sorted on Entry::unicode. All 'unicode' fields are unique, but
47 // there can be different entries that have the same 'msx' field.
48 std::vector<Entry> unicode2msx;
49};
50
51} // namespace openmsx
52
53#endif
std::vector< uint8_t > utf8ToMsx(std::string_view utf8, const std::function< uint8_t(uint32_t)> &fallback) const
TODO.
std::string msxToUtf8(std::span< const uint8_t > msx, const std::function< uint32_t(uint8_t)> &fallback) const
TODO.
This file implemented 3 utility functions:
Definition Autofire.cc:11