export class Symbol_Codes {
decode_table: Map<string, string>;
encode_table: Map<string, string>;
constructor(symbols: Symbol_Code[]) { this.decode_table = new Map(symbols.map(s => [s.symbol, codepoint_string(s.code)])); this.encode_table = new Map(symbols.map(s => [codepoint_string(s.code), s.symbol]));
}
recode(str: string, do_encode: boolean): string { function ok(i: number): boolean { return0 <= i && i < str.length;
} functionchar(i: number): number { return ok(i) ? str.charCodeAt(i) : 0;
} function maybe_char(c: number, i: number): number { returnchar(i) === c ? i + 1 : i;
}
function many_ascii_letdig(i: number): number {
let k = i; while (is_ascii_letdig(char(k))) { k += 1 }; return k;
} function maybe_ascii_id(i: number): number { return is_ascii_letter(char(i)) ? many_ascii_letdig(i + 1) : i
}
function scan_ascii(start: number): string {
let i = start; while (ok(i)) { const a = char(i); const b = char(i + 1); if (!is_ascii(a) || a === backslash && b === bg_symbol) { break; } else { i += 1; }
} return str.substring(start, i);
}
function scan_symbol(i: number): string { const a = char(i); const b = char(i + 1); if (a === backslash && b === bg_symbol) { const j = maybe_char(en_symbol, maybe_ascii_id(maybe_char(caret, i + 2))); return str.substring(i, j);
} else { return''; }
}
function scan_codepoint(i: number): string { const c = str.codePointAt(i); return c === undefined ? '' : codepoint_string(c);
}
const table = do_encode ? this.encode_table : this.decode_table; const result = new String_Buffer();
let i = 0; while (ok(i)) { const ascii = scan_ascii(i) if (ascii) {
result.add(ascii)
i += ascii.length
} else { const s = scan_symbol(i) || scan_codepoint(i); if (s) { const r = table.get(s);
result.add(r === undefined ? s : r);
i += s.length;
}
}
} return result.end();
}
}
const symbol_codes: Symbol_Codes = new Symbol_Codes([/*symbols*/]);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.