mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-28 13:36:16 +02:00
* Create bundle filenames to spec
* Better cp437 vs utf8 vs other encoding support * Add some CP437 and related utils
This commit is contained in:
parent
1f1813c14a
commit
8817113364
5 changed files with 191 additions and 25 deletions
|
@ -13,6 +13,7 @@ exports.pad = pad;
|
|||
exports.insert = insert;
|
||||
exports.replaceAt = replaceAt;
|
||||
exports.isPrintable = isPrintable;
|
||||
exports.containsNonLatinCodepoints = containsNonLatinCodepoints;
|
||||
exports.stripAllLineFeeds = stripAllLineFeeds;
|
||||
exports.debugEscapedString = debugEscapedString;
|
||||
exports.stringFromNullTermBuffer = stringFromNullTermBuffer;
|
||||
|
@ -196,6 +197,20 @@ function isPrintable(s) {
|
|||
return !RE_NON_PRINTABLE.test(s);
|
||||
}
|
||||
|
||||
const NonLatinCodePointsRegExp = /[^\u0000-\u00ff]/;
|
||||
|
||||
function containsNonLatinCodepoints(s) {
|
||||
if (!s.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s.charCodeAt(0) > 255) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return NonLatinCodepointsRegEx.test(s);
|
||||
}
|
||||
|
||||
function stripAllLineFeeds(s) {
|
||||
return s.replace(/\r?\n|[\r\u2028\u2029]/g, '');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue