ASCII Lookup Table Generator

This page may be used to generate a bit-packed ascii lookup table.
Choose the characters you want to include in your table.
A function will be generated at the bottom of this page.



SAVE CODE

C/C++

unsigned char lookup(unsigned char c) {
    return (((""
        :T:
        "")[c>>:0:])>>((c&:1:)<<:2:)&:3:);
}

Go

func lookup(c byte) byte {
    return (((""+
        :T:+
        "")[c>>:0:])>>((c&:1:)<<:2:)&:3:);
}

Zig

fn lookup(c: u8) u8 {
    return (((""++
        :T:++
        "")[c>>:0:])>>(@truncate(c&:1:)<<:2:)&:3:);
}

Rust

const fn lookup(c: u8) -> u8 {
    (((b"\
        :T:
        ")[(c>>:0:)as usize])>>((c&:1:)<<:2:)&:3:)
}

Copyright 2026 - Josh Baker
tidwall.com