HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
CP1252.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include <cstddef>
8
9namespace hi::inline v1 {
10
11[[nodiscard]] constexpr char32_t CP1252_to_UTF32(char inputCharacter) noexcept
12{
13 hilet inputCharacter_ = static_cast<uint8_t>(inputCharacter);
14 if (inputCharacter_ <= 0x7f) {
15 return inputCharacter_;
16 } else if (inputCharacter_ >= 0xa0) {
17 return inputCharacter_;
18 } else {
19 switch (inputCharacter_) {
20 case 0x80: return 0x20ac;
21 case 0x81: return 0xfffd; // Replacement character.
22 case 0x82: return 0x201a;
23 case 0x83: return 0x0192;
24 case 0x84: return 0x201e;
25 case 0x85: return 0x2026;
26 case 0x86: return 0x2020;
27 case 0x87: return 0x2021;
28 case 0x88: return 0x02c6;
29 case 0x89: return 0x2030;
30 case 0x8a: return 0x0160;
31 case 0x8b: return 0x2039;
32 case 0x8c: return 0x0152;
33 case 0x8d: return 0xfffd; // Replacement character.
34 case 0x8e: return 0x017d;
35 case 0x8f: return 0xfffd; // Replacement character.
36 case 0x90: return 0xfffd; // Replacement character.
37 case 0x91: return 0x2018;
38 case 0x92: return 0x2019;
39 case 0x93: return 0x201c;
40 case 0x94: return 0x201d;
41 case 0x95: return 0x2022;
42 case 0x96: return 0x2013;
43 case 0x97: return 0x2014;
44 case 0x98: return 0x02dc;
45 case 0x99: return 0x2122;
46 case 0x9a: return 0x0161;
47 case 0x9b: return 0x203a;
48 case 0x9c: return 0x0153;
49 case 0x9d: return 0xfffd; // Replacement character.
50 case 0x9e: return 0x017e;
51 case 0x9f: return 0x0178;
52 default: return 0xfffd; // Replacement character.
53 }
54 }
55}
56
57} // namespace hi::inline v1
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23