Public
Edited
May 19, 2024
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
control = await gunzip(await FileAttachment("unicode-15.1.0-names-control.json.gz").blob()).json()
Insert cell
names = await gunzip(await FileAttachment("unicode-15.1.0-names.json.gz").blob()).json()
Insert cell
function gunzip(data) {
return new Response(new Blob([data]).stream().pipeThrough(new DecompressionStream('gzip')))
}
Insert cell
// modified from https://github.com/node-unicode/unicode-15.1.0/blob/main/decode-property-map.js
function* generateEntries(runs) {
const len = runs.length - 2
for (let cp = 0, i = 0; i < len; /* i++ */) {
cp += runs[i++]
const end = cp + (runs[i++])
const value = runs[i++]
while (cp < end) {
yield [cp++, value]
}
}
}
Insert cell
getNameByCodePoint = {
const map = new Map(
Object.entries(control).map(([k, v]) => [Number(k), v.at(0)])
)
const generator = generateEntries(names)
return function getNameByCodePoint(codePoint) {
while (true) {
const { value } = generator.next()
if (!value) break
const [cp, name] = value
if (!map.has(cp)) {
map.set(cp, name)
}
if (cp >= codePoint) break
}
return map.get(codePoint) ?? null
}
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more