本文整理汇总了C#中System.Text.ASCIIEncoding.GetEncoder方法的典型用法代码示例。如果您正苦于以下问题:C# ASCIIEncoding.GetEncoder方法的具体用法?C# ASCIIEncoding.GetEncoder怎么用?C# ASCIIEncoding.GetEncoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.ASCIIEncoding
的用法示例。
在下文中一共展示了ASCIIEncoding.GetEncoder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest1
public void PosTest1()
{
ASCIIEncoding ascii;
Encoder actualEncoder;
ascii = new ASCIIEncoding();
actualEncoder = ascii.GetEncoder();
Assert.NotNull(actualEncoder);
}
示例2: PutFile
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;
}