public static Buf fromHex(string s)
{
int slen = s.Length;
byte[] buf = new byte[slen/2];
int[] hexInv = Buf.hexInv;
int size = 0;
for (int i=0; i<slen; ++i)
{
int c0 = s[i];
int n0 = c0 < 128 ? hexInv[c0] : -1;
if (n0 < 0) continue;
int n1 = -1;
if (++i < slen)
{
int c1 = s[i];
n1 = c1 < 128 ? hexInv[c1] : -1;
}
if (n1 < 0) throw IOErr.make("Invalid hex str").val;
buf[size++] = (byte)((n0 << 4) | n1);
}
return new MemBuf(buf, size);
}