public static byte[] FromGSM7BitPacked(byte[] bytes) { BitStream stream = new BitStream(new byte[0]); byte[] bytesa = new byte[bytes.Length]; for (int i = 0, j = bytes.Length - 1; i < bytes.Length; i++, j--) bytesa[j] = bytes[i]; string stra = stream.ToBitString(bytesa); string strb = ""; for (int i = stra.Length-1; (i/7) > 0; i -= 7) strb = string.Format("{0}0{1}", strb, stra.Substring(i - 6, 7)); stream.parseBitString(strb); byte[] bytese = stream.ToBytes(); return bytese; }
public static byte[] ToGSM7BitPacked(byte[] bytes) { BitStream stream = new BitStream(new byte[0]); string strb = stream.ToBitString(bytes); string strc = ""; for (int i = 1; i < strb.Length; i += 8) { strc = string.Format("{0}{1}", strb.Substring(i, 7), strc); } while (strc.Length % 8 > 0) strc = string.Format("{0}{1}", 0, strc); stream.parseBitString(strc); byte[] bytesd = stream.ToBytes(); byte[] bytese = new byte[bytesd.Length]; for (int i = 0, j = bytesd.Length - 1; i < bytesd.Length; i++, j--) bytese[j] = bytesd[i]; return bytese; }