Replace characters < 0x20 that aren't IRC formatting with their U+24xx equivalents
This commit is contained in:
parent
902804cf2f
commit
46f7854d13
|
@ -24,7 +24,6 @@ TODO
|
|||
* Make VM and transformMultiplyLoops use a Proxied object that gives out 0
|
||||
for nonexistent elements for tape and allows using [] interface
|
||||
* Keep a cache of compiled programs in `ircbotRun()`
|
||||
* Replace non-IRC low bytes with their U+2400 versions in `ircbotRun()`
|
||||
* Support for other types of EOF?
|
||||
|
||||
### gir.html
|
||||
|
|
12
gir.js
12
gir.js
|
@ -937,6 +937,18 @@ function ircbotRun(program, input, maxCycles = 400000) {
|
|||
let result = runVM(vm, maxCycles);
|
||||
let output = decodeUTF8(result.state.output);
|
||||
|
||||
// Replace all characters < 0x20 except for IRC formatting codes
|
||||
// with their graphical representations at U+24xx
|
||||
let formattingChars = [0x02, 0x03, 0x0f, 0x12, 0x15];
|
||||
output = Array.from(output).map(c => {
|
||||
let codePoint = c.codePointAt(0);
|
||||
if(codePoint < 0x20 && !formattingChars.includes(codePoint)) {
|
||||
return String.fromCodePoint(0x2400 + codePoint);
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
}).join('');
|
||||
|
||||
// Did we run into maxCycles?
|
||||
let executedTooLong = maxCycles != null &&
|
||||
result.cycles >= maxCycles;
|
||||
|
|
Loading…
Reference in New Issue