mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-12 07:44:03 +09:00
hangul assembler; adding Unicode conversion function to the TVDOS
This commit is contained in:
@@ -281,6 +281,44 @@ Object.freeze(input);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const unicode = {};
|
||||
unicode.utf8toCodepoints = function(utf8text) {
|
||||
let UTF8_ACCEPT = 0
|
||||
let UTF8D = [
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
|
||||
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
|
||||
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
|
||||
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
|
||||
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
|
||||
12,36,12,12,12,12,12,12,12,12,12,12,
|
||||
]
|
||||
|
||||
let state = UTF8_ACCEPT
|
||||
let codep = 0
|
||||
let codepoints = []
|
||||
|
||||
for (let i=0; i < utf8text.length; i++) {
|
||||
let byte = utf8text.charCodeAt(i)
|
||||
let type = UTF8D[byte]
|
||||
codep = (state != UTF8_ACCEPT) ?
|
||||
(byte & 0x3f) | (codep << 6) : (0xff >> type) & (byte)
|
||||
state = UTF8D[256 + state + type]
|
||||
if (state == UTF8_ACCEPT)
|
||||
codepoints.push(codep)
|
||||
}
|
||||
return codepoints
|
||||
}
|
||||
Object.freeze(unicode);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// install other stuffs
|
||||
filesystem.open("A", "tvdos/gl.js", "R");
|
||||
const GL = eval(filesystem.readAll("A"));
|
||||
|
||||
Reference in New Issue
Block a user