public byte[] CharToByte(String text, String encoding) { char[] cc = text.ToCharArray(); byte[] b = new byte[cc.Length]; int ptr = 0; int len = cc.Length; for (int k = 0; k < len; ++k) { char c = cc[k]; byte v = (byte)translation[(int)c]; if (v != 0) b[ptr++] = v; } if (ptr == len) return b; byte[] b2 = new byte[ptr]; Array.Copy(b, 0, b2, 0, ptr); return b2; }