Skip to content

Instantly share code, notes, and snippets.

@spraints
Created September 30, 2009 20:28
Show Gist options
  • Select an option

  • Save spraints/198411 to your computer and use it in GitHub Desktop.

Select an option

Save spraints/198411 to your computer and use it in GitHub Desktop.
def printable(c)
c.sub!(/\d/) { |d| "_#{d}" }
{
'/' => '_slash_',
'_' => '_underscore_'
}[c] || c
end
(0..127).each do |n|
c = printable(n.chr)
printf " private const byte %s = 0x%02x;\n", c, n if c =~ /^\w+$/
end
private const byte _slash_ = 0x2f;
private const byte _0 = 0x30;
private const byte _1 = 0x31;
private const byte _2 = 0x32;
private const byte _3 = 0x33;
private const byte _4 = 0x34;
private const byte _5 = 0x35;
private const byte _6 = 0x36;
private const byte _7 = 0x37;
private const byte _8 = 0x38;
private const byte _9 = 0x39;
private const byte A = 0x41;
private const byte B = 0x42;
private const byte C = 0x43;
private const byte D = 0x44;
private const byte E = 0x45;
private const byte F = 0x46;
private const byte G = 0x47;
private const byte H = 0x48;
private const byte I = 0x49;
private const byte J = 0x4a;
private const byte K = 0x4b;
private const byte L = 0x4c;
private const byte M = 0x4d;
private const byte N = 0x4e;
private const byte O = 0x4f;
private const byte P = 0x50;
private const byte Q = 0x51;
private const byte R = 0x52;
private const byte S = 0x53;
private const byte T = 0x54;
private const byte U = 0x55;
private const byte V = 0x56;
private const byte W = 0x57;
private const byte X = 0x58;
private const byte Y = 0x59;
private const byte Z = 0x5a;
private const byte _ = 0x5f;
private const byte a = 0x61;
private const byte b = 0x62;
private const byte c = 0x63;
private const byte d = 0x64;
private const byte e = 0x65;
private const byte f = 0x66;
private const byte g = 0x67;
private const byte h = 0x68;
private const byte i = 0x69;
private const byte j = 0x6a;
private const byte k = 0x6b;
private const byte l = 0x6c;
private const byte m = 0x6d;
private const byte n = 0x6e;
private const byte o = 0x6f;
private const byte p = 0x70;
private const byte q = 0x71;
private const byte r = 0x72;
private const byte s = 0x73;
private const byte t = 0x74;
private const byte u = 0x75;
private const byte v = 0x76;
private const byte w = 0x77;
private const byte x = 0x78;
private const byte y = 0x79;
private const byte z = 0x7a;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment