Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Created June 28, 2023 19:05
Show Gist options
  • Save DV8FromTheWorld/2490d4089b51f2ec14cec18693ed1082 to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/2490d4089b51f2ec14cec18693ed1082 to your computer and use it in GitHub Desktop.
Small helper browser console function for pulling info out of the Unicode Confusables site
function getConfusableCharacters() {
const confusableCharactersTable = document.querySelector('table:has(h3)')
const tableRows = confusableCharactersTable.querySelectorAll('tr')
const unicodeRow = Array.from(tableRows[1].children)
const nameRow = Array.from(tableRows[2].children)
let values = ''
for (let i = 0; i < unicodeRow.length; i++) {
const unicode = unicodeRow[i].innerText
const name = nameRow[i].innerText
values += `'\\u{${unicode}}', // ${name}\n`
}
return values
}
@DV8FromTheWorld
Copy link
Author

DV8FromTheWorld commented Jun 28, 2023

This script is intended to be run from the browser console when on the Unicode Confusables site
https://util.unicode.org/UnicodeJsps/confusables.jsp

Search for the character that you want to get the confusables for, then open the console, paste this function code, and then run the code.

getConfusableCharacters()

If in chrome, you can simplify getting the result into your clipboard by using the built in copy(...) function

copy(getConfusableCharacters())

For example, given a search for /: https://util.unicode.org/UnicodeJsps/confusables.jsp?a=%2F&r=None
image
image

'\u{002F}', // SOLIDUS
'\u{1735}', // PHILIPPINE SINGLE PUNCTUATION
'\u{2041}', // CARET INSERTION POINT
'\u{2044}', // FRACTION SLASH
'\u{2215}', // DIVISION SLASH
'\u{2571}', // BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT
'\u{27CB}', // MATHEMATICAL RISING DIAGONAL
'\u{29F8}', // BIG SOLIDUS
'\u{2CC6}', // COPTIC CAPITAL LETTER OLD COPTIC ESH
'\u{2F03}', // KANGXI RADICAL SLASH
'\u{3033}', // VERTICAL KANA REPEAT MARK UPPER HALF
'\u{30CE}', // KATAKANA LETTER NO
'\u{31D3}', // CJK STROKE SP
'\u{4E3F}', // CJK UNIFIED IDEOGRAPH-4E3F
'\u{1D23A}', // GREEK INSTRUMENTAL NOTATION SYMBOL-47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment