Cascadia vs Consolas

By Xah Lee. Date: .
font cascadia mono 2024-10-05 mMZNb
font cascadia mono 2024-10-05 mMZNb
font consolas 2024-10-05 7SvS6
font consolas 2024-10-05 7SvS6

Cascadia Mono and Consolas on Microsoft Windows

The following will display with the correct font only if you have the font. e.g. you are on Microsoft Windows, 10 or later.

// using font Cascadia Mono

/* return the hexadecimal string of the char's utf16 encoding.
string is separated by space for each char
 */
const f_charID_to_utf16_hexStr = (CharID: number): string => {
  const xCharStr = String.fromCodePoint(CharID);
  if (CharID < 2 ** 16) {
    return xCharStr.charCodeAt(0).toString(16).toUpperCase();
  } else {
    const xLen = String.fromCodePoint(CharID).length;
    const xResultArray = [];
    for (let i = 0; i < xLen; i++) {
      xResultArray.push(xCharStr.charCodeAt(i).toString(16).toUpperCase());
    }
    return xResultArray.join(" ");
  }
};
// using font consolas

/* return the hexadecimal string of the char's utf16 encoding.
string is separated by space for each char
 */
const f_charID_to_utf16_hexStr = (CharID: number): string => {
  const xCharStr = String.fromCodePoint(CharID);
  if (CharID < 2 ** 16) {
    return xCharStr.charCodeAt(0).toString(16).toUpperCase();
  } else {
    const xLen = String.fromCodePoint(CharID).length;
    const xResultArray = [];
    for (let i = 0; i < xLen; i++) {
      xResultArray.push(xCharStr.charCodeAt(i).toString(16).toUpperCase());
    }
    return xResultArray.join(" ");
  }
};