public void PosTest1() { ASCIIEncoding ascii; Encoder actualEncoder; ascii = new ASCIIEncoding(); actualEncoder = ascii.GetEncoder(); Assert.NotNull(actualEncoder); }
static public int GetEncoder(IntPtr l) { try { System.Text.ASCIIEncoding self = (System.Text.ASCIIEncoding)checkSelf(l); var ret = self.GetEncoder(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public int PutFile(string filename) { byte[] txBuf = new byte[516]; int txCount; string s = System.IO.File.ReadAllText(filename); System.IO.StringReader sr = new System.IO.StringReader(s); short blockNumber; ASCIIEncoding ae = new ASCIIEncoding(); sendTftpPacket(Client.OP_CODE.WRQ, filename, null, -1);//send WRQ char[] chunk = new char[512]; int dataLength = sr.ReadBlock(chunk,0,512); do { txCount = recvTftpPacket(ref txBuf); OP_CODE op = (OP_CODE)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(txBuf, 0)); System.Diagnostics.Debug.Assert(op==OP_CODE.ACK); blockNumber = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(txBuf, 2)); //s += new string(ae.GetChars(rxBuf, sizeof(short) * 2, rxCount - 4 >= 4 ? rxCount - 4 : 0)); byte[] data = new byte[dataLength]; int chrCount,byteCount; bool completed; ae.GetEncoder().Convert(chunk,0,dataLength,data,0,data.Length,true,out chrCount,out byteCount,out completed); sendTftpPacket(Client.OP_CODE.DATA, string.Empty, data, ++blockNumber); } while ((dataLength=sr.ReadBlock(chunk, 0, 512)) == 512); //sendTftpPacket(Client.OP_CODE.ACK, string.Empty, null, blockNumber);//final ACK return txCount; }