summaryrefslogtreecommitdiffstats
path: root/src/caseconvert.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/caseconvert.py')
-rw-r--r--src/caseconvert.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/caseconvert.py b/src/caseconvert.py
index 0b0b57b..ef7e403 100644
--- a/src/caseconvert.py
+++ b/src/caseconvert.py
@@ -10,10 +10,10 @@ tolower = {}
def writeMapping(file,mapping):
for k,v in sorted(mapping.items()):
- file.write(u" case %s /* %s */: return u8\"%s\" /* %s */;\n" %
- (hex(ord(k[0])),k,v,",".join("0x{:02x}".format(ord(c)) for c in v)))
+ file.write(u" case %s /* %s */: BSEQ(%s) /* %s */;\n" %
+ (hex(ord(k[0])), k, ",".join(f"0x{b:02x}" for b in v.encode('utf-8')), v))
-# create mappings of characters whose upper and lower case differs
+# create mappings of characters whose upper and lower case differ
for codeValue in range(0,0x1FFFF):
s = chr(codeValue)
sl = s.lower()
@@ -32,6 +32,9 @@ file.write(r'''/** This file is generated by python3 caseconvert.py. DO NOT EDIT
#include <cstdint>
#include <string>
+#define BSEQ(...) { static unsigned char s[] = { __VA_ARGS__, 0x00 }; \
+ return reinterpret_cast<const char *>(s); }
+
inline const char *convertUnicodeToUpper(uint32_t code)
{
switch(code)