_compose_pair

func _compose_pair(starter: Int, combining: Int) -> Int?

Looks up canonical composition for a starter and following combining scalar.

Hangul syllables are composed algorithmically; all other pairs use the generated Unicode composition table. none leaves the pair decomposed.

View Source
pub func _compose_pair(starter: Int, combining: Int) -> Int? {
	let table = _composition_table()
	let width = 9
	let lo = 0
	let hi = table.byte_count / width - 1
	loop lo <= hi {
		let mid = (lo + hi) / 2
		let base = mid * width
		let left = _septet_value(storage: table.storage, start: base, width: 3)
		let right = _septet_value(storage: table.storage, start: base + 3, width: 3)
		if starter < left || (starter == left && combining < right) {
			hi = mid - 1
		} else {
			if starter > left || (starter == left && combining > right) {
				lo = mid + 1
			} else {
				return .some(_septet_value(storage: table.storage, start: base + 6, width: 3))
			}
		}
	}
	.none
}