phpChr
Encodes and decodes as the php chr() function
Created by: hackvertor
Installed 1 times
Category: Convert
Created on: Friday, December 20, 2024 at 2:27:35 PM
Updated on: Saturday, December 21, 2024 at 11:40:18 AM
Tag arguments
[]
Code
class phpChr {
encode(input) {
return input
.replaceAll(/[\x00-\xff]/gi, function (c) {
return "chr(" + c.codePointAt(0) + ").";
})
.replace(/[.]$/, "");
}
decode(input) {
return input.replaceAll(/chr[(][\d]+[)][.]?/g, function (c) {
return String.fromCodePoint(c.replace(/chr[(]|[)]/g, ""));
});
}
matches(input) {
return /^chr[(][\d]+[)][.]?/g.exec(input);
}
}