Skip to content

Instantly share code, notes, and snippets.

@fdstevex
Created July 27, 2020 11:15
Show Gist options
  • Save fdstevex/9fef9d648cb29abe22da5b958c722a22 to your computer and use it in GitHub Desktop.
Save fdstevex/9fef9d648cb29abe22da5b958c722a22 to your computer and use it in GitHub Desktop.
// How is it I can use SF Symbols images in text strings?
echo >bug.txt 􀌛
hexdump bug.txt
> f4 80 8c 9b
f4 = 11110100
80 = 10000000
8c = 10001100
9b = 10011011
First byte starts with 1111 which means it's
a 4 byte value.
Wikipedia explains how to decode this:
https://en.wikipedia.org/wiki/UTF-8
100000000001100011011 = 0x10031B
0x100000-0x10FFFF is "Supplementary Private Use Area-B"
// Gist of a small Swift script that prints all the characters in the
// private use block.
https://gist.github.com/fdstevex/5412fad1d205e8b00ad6288e0769389b
#!/bin/swift
import Cocoa
for ch:UInt32 in 0x100000..<0x10FFFF {
let arr = [ch]
let array: [UInt32] = [CFSwapInt32(ch)]
let data = array.withUnsafeBytes { (ptr) -> Data in
return Data(ptr)
}
if let str = String(data: data, encoding: .utf32) {
print("\(String(format: "%08X", ch)): \(str)")
}
}
0010074A: 􀝊
0010074B: 􀝋
0010074C: 􀝌
0010074D: 􀝍
0010074E: 􀝎
0010074F: 􀝏
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment