Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
2.6 KB
Raw Blame
/** ASCII stand-ins for characters no installed face can draw. */

/**
 * ASCII stand-ins for symbols models reach for constantly. Charts apply them
 * only when the character cannot be drawn; PDFs always apply them to emoji,
 * which no embedded face draws in color.
 */
export const SUBSTITUTIONS: Record<string, string> = {
  '\u2192': '->',
  '\u27F6': '->',
  '\u279C': '->',
  '\u2794': '->',
  '\u2190': '<-',
  '\u2194': '<->',
  '\u21D2': '=>',
  '\u21D0': '<=',
  '\u21D4': '<=>',
  '\u2191': '^',
  '\u2193': 'v',
  '\u2713': 'OK',
  '\u2714': 'OK',
  '\u2611': '[x]',
  '\u2717': 'X',
  '\u2718': 'X',
  '\u2612': '[x]',
  '\u2248': '~',
  '\u2265': '>=',
  '\u2264': '<=',
  '\u2260': '!=',
  '\u2261': '==',
  '\u221E': 'inf',
  '\u2022': '*',
  '\u2023': '-',
  '\u25AA': '-',
  '\u25AB': '-',
  '\u25E6': '-',
  '\u25CF': '*',
  '\u25CB': 'o',
  '\u2605': '*',
  '\u2606': '*',
  '\u26A0': '!',
  '\u2122': '(TM)',
  '\u2120': '(SM)',
  '\u2014': '-',
  '\u2013': '-',
  '\u2026': '...',
  '\u201C': '"',
  '\u201D': '"',
  '\u2018': "'",
  '\u2019': "'",
  '\u2010': '-',
  '\u2011': '-',
  '\u2212': '-',
  // Space variants: locale-formatted numbers and times carry U+202F and U+00A0.
  '\u00A0': ' ',
  '\u2000': ' ',
  '\u2001': ' ',
  '\u2002': ' ',
  '\u2003': ' ',
  '\u2004': ' ',
  '\u2005': ' ',
  '\u2006': ' ',
  // A figure space and a narrow no-break space keep a number or a time such as
  // '8:11 PM' on one line, so they stand in as a no-break space.
  '\u2007': '\u00A0',
  '\u2008': ' ',
  '\u2009': ' ',
  '\u200A': ' ',
  '\u202F': '\u00A0',
  '\u205F': ' ',
  '\u3000': ' ',
  // Status emoji, which models often put alone in a table cell. No embedded
  // face draws them in colour, and a coloured circle means only its colour,
  // so they become words.
  '\u2705': 'OK',
  '\u2716': 'X',
  '\u274c': 'X',
  '\u274e': 'X',
  '\u2757': '!',
  '\u2755': '!',
  '\u2753': '?',
  '\u2754': '?',
  '\u2b50': '*',
  '\u2b06': '^',
  '\u2b07': 'v',
  '\u27a1': '->',
  '\u2b05': '<-',
  '\u{1F7E2}': '(green)',
  '\u{1F7E1}': '(yellow)',
  '\u{1F7E0}': '(orange)',
  '\u{1F534}': '(red)',
  '\u{1F535}': '(blue)',
  '\u{1F7E3}': '(purple)',
  '\u{1F7E4}': '(brown)',
  '\u26ab': '(black)',
  '\u26aa': '(white)',
  '\u{1F7E9}': '(green)',
  '\u{1F7E8}': '(yellow)',
  '\u{1F7E7}': '(orange)',
  '\u{1F7E5}': '(red)',
  '\u{1F7E6}': '(blue)',
  '\u{1F7EA}': '(purple)',
  '\u{1F7EB}': '(brown)',
  '\u2b1b': '(black)',
  '\u2b1c': '(white)',
  '\u{1F4C8}': '(up)',
  '\u{1F4C9}': '(down)',
}

/** The ASCII stand-in for a symbol or status emoji, when one is defined. */
export function asciiStandIn(ch: string): string | undefined {
  return SUBSTITUTIONS[ch]
}