GetEncoder() public method

public GetEncoder ( ) : System.Text.Encoder
return System.Text.Encoder
Ejemplo n.º 1
0
        public void PosTest1()
        {
            ASCIIEncoding ascii;
            Encoder actualEncoder;

            ascii = new ASCIIEncoding();
            actualEncoder = ascii.GetEncoder();
            Assert.NotNull(actualEncoder);
        }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
        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;
        }