JSFiddle - React, Tailwind, and code Playground
JavaScript
function Range(start, end)
{
var result = [];
if ($.isNumeric(start) && $.isNumeric(end))
{
result = new Array(end - start + 1).fill().map((d, i) => i + start);
} else
{
var arr = new Array(end.charCodeAt() - start.charCodeAt() + 1).fill().map((d, i) => String.fromCharCode(i + start.charCodeAt())),
str = String(arr);
if ((/[А-Яё]/gi).test(str)) RegExp = (/[А-Яё]/gi);
if ((/[A-Z]/gi).test(str)) RegExp = (/[A-Z]/gi);
result = str.match(RegExp);
}
return result;
}
function UnicodeParse(arr, str)
{
var result = [];
for (var i = 0; i < arr.length; i++)
{
var a = arr[i];
if ($.isNumeric(arr[0]))
{
if (str == 'cod')
{
result[i] = String.fromCharCode(a);
}
if (str == 'arr')
{
result[a] = String.fromCharCode(a);
}
} else
{
if (str == 'cod')
{
result[i] = a.charCodeAt();
}
if (str == 'arr')
{
result[a] = a.charCodeAt();
}
}
}
return result;
}
console.log(Range(72, 79));
console.log(UnicodeParse(Range(72, 79), 'cod'));
console.log(UnicodeParse(Range(72, 79), 'arr'));
console.log(Range('A', 'z'));
console.log(UnicodeParse(Range('A', 'z'), 'cod'));
console.log(UnicodeParse(Range('A', 'z'), 'arr'));
console.log(Range('Ё', 'ё'));
console.log(UnicodeParse(Range('Ё', 'ё'), 'cod'));
console.log(UnicodeParse(Range('Ё', 'ё'), 'arr'));