mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-05-04 18:13:07 +03:00
Use Number.parseInt()
for hexadecimal/decimal conversions (#11902)
This commit is contained in:
parent
15a821e895
commit
14ccea31a8
@ -140,22 +140,6 @@ const getTitleTextIndex = (svgFileContent) => {
|
|||||||
return svgFileContent.indexOf(titleStart) + titleStart.length;
|
return svgFileContent.indexOf(titleStart) + titleStart.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a hexadecimal number passed as string to decimal number as integer.
|
|
||||||
* @param {string} hex The hexadecimal number representation to convert.
|
|
||||||
* @returns {number} The decimal number representation.
|
|
||||||
*/
|
|
||||||
const hexadecimalToDecimal = (hex) => {
|
|
||||||
let result = 0;
|
|
||||||
let digitValue;
|
|
||||||
for (const digit of hex.toLowerCase()) {
|
|
||||||
digitValue = '0123456789abcdefgh'.indexOf(digit);
|
|
||||||
result = result * 16 + digitValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shorten a string with ellipsis if it exceeds 20 characters.
|
* Shorten a string with ellipsis if it exceeds 20 characters.
|
||||||
* @param {string} string_ The string to shorten.
|
* @param {string} string_ The string to shorten.
|
||||||
@ -300,7 +284,7 @@ const config = {
|
|||||||
for (const match of hexadecimalCodepoints) {
|
for (const match of hexadecimalCodepoints) {
|
||||||
const charHexReprIndex =
|
const charHexReprIndex =
|
||||||
getTitleTextIndex(ast.source) + match.index + 1;
|
getTitleTextIndex(ast.source) + match.index + 1;
|
||||||
const charDec = hexadecimalToDecimal(match[1]);
|
const charDec = Number.parseInt(match[1], 16);
|
||||||
|
|
||||||
let charRepr;
|
let charRepr;
|
||||||
if (xmlNamedEntitiesCodepoints.includes(charDec)) {
|
if (xmlNamedEntitiesCodepoints.includes(charDec)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user