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];
if (c < 128)
b[ptr++] = (byte)c;
else {
byte v = (byte)c2b[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;
}