本文整理汇总了C#中System.Text.ASCIIEncoding.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.ASCIIEncoding.GetString方法的具体用法?C# System.Text.ASCIIEncoding.GetString怎么用?C# System.Text.ASCIIEncoding.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.ASCIIEncoding
的用法示例。
在下文中一共展示了System.Text.ASCIIEncoding.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ByteArrayToStr
public static string ByteArrayToStr(byte[] dBytes)
{
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(dBytes);
return str;
}
示例2: ByteArrayToString
public static string ByteArrayToString(byte[] b)
{
string s;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
s = enc.GetString(b, 0, b.Length);
return s;
}
示例3: Encode
public void Encode(IPEndPoint local_endpoint)
{
Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Bind (local_endpoint);
sock.Listen (5);
// for (;;)
// {
// allDone.Reset ();
// Console.Error.WriteLine ("Waiting for connection on port {0}", local_endpoint);
// sock.BeginAccept (new AsyncCallback (this.AcceptCallback), sock);
// allDone.WaitOne ();
// }
Console.Error.WriteLine ("Waiting for connection on port {0}", local_endpoint);
Socket client = sock.Accept();
NetworkStream stream = new NetworkStream(client);
Console.Error.WriteLine ("Got connection from {0}", client.RemoteEndPoint);
byte[] buffer = new byte[1024];
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
Stream stdin = Console.OpenStandardInput(buffer.Length);
while (stdin.Read(buffer, 0, buffer.Length) != 0)
{
Console.WriteLine("Data: {0}", encoding.GetString(buffer));
stream.Write(buffer, 0, buffer.Length);
}
Console.Error.WriteLine ("Closing socket");
sock.Close ();
}
示例4: BatchUpload
public ActionResult BatchUpload(DateTime date, HttpPostedFileBase file, int? fundid, string text)
{
string s;
if (file != null)
{
byte[] buffer = new byte[file.ContentLength];
file.InputStream.Read(buffer, 0, file.ContentLength);
System.Text.Encoding enc = null;
if (buffer[0] == 0xFF && buffer[1] == 0xFE)
{
enc = new System.Text.UnicodeEncoding();
s = enc.GetString(buffer, 2, buffer.Length - 2);
}
else
{
enc = new System.Text.ASCIIEncoding();
s = enc.GetString(buffer);
}
}
else
s = text;
var id = PostBundleModel.BatchProcess(s, date, fundid);
if (id.HasValue)
return Redirect("/PostBundle/Index/" + id);
return RedirectToAction("Batch");
}
示例5: ErrorString
public static string ErrorString(uint hekkaError)
{
byte[] text = new byte[200];
int size = text.Length;
IntPtr textPtr = Marshal.AllocHGlobal(size);
string result = null;
try
{
ITCMM.ITC_AnalyzeError((int)hekkaError, textPtr, (uint)size);
Marshal.Copy(textPtr, text, 0, size);
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
result = enc.GetString(text);
}
finally
{
Marshal.FreeHGlobal(textPtr);
}
return result;
}
示例6: ExtractMetaData
public new Boolean ExtractMetaData()
{
// Create an Image object.
System.Drawing.Image image = new Bitmap(@"G:\projects\MugShot\test_photos\ClayShoot0001.JPG");
// Get the PropertyItems property from image.
PropertyItem[] propItems = image.PropertyItems;
// For each PropertyItem in the array, display the ID, type, and
// length.
int count = 0;
foreach (PropertyItem propItem in propItems)
{
Console.WriteLine(propItem.Id.ToString("x"));
Console.WriteLine(propItem.Type.ToString());
Console.WriteLine(propItem.Len.ToString());
Console.WriteLine("-----------------------");
count++;
}
// Convert the value of the second property to a string, and display
// it.
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
string manufacturer = encoding.GetString(propItems[1].Value);
Console.WriteLine("Manufacturer: {0}", manufacturer.ToString());
//need to fill this in with real metadata
MetaData = new ArrayList();
return true;
}
示例7: GetExifPropertyTagDateTime
public static string GetExifPropertyTagDateTime(string file)
{
const int PropertyTagDateTime = 0x0132;
string DateTime = "";
try {
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
using (FileStream stream = File.OpenRead(file)) {
Image image = Image.FromStream(stream, true, false);
PropertyItem[] propItems = image.PropertyItems;
// For each PropertyItem in the array, display the ID, type, and length and value.
// 0x0132 _=
foreach (PropertyItem propItem in propItems) {
if (propItem.Id == PropertyTagDateTime) {
DateTime = encoding.GetString(propItem.Value);
break;
}
}
}
} catch (Exception) {
// if there was an error (such as read a defect image file), just ignore
}
return(DateTime);
}
示例8: ByteArrayToString
public static string ByteArrayToString(byte[] arr)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string result = System.Text.Encoding.UTF8.GetString(arr);
string result2 = enc.GetString(arr);
string s3 = Convert.ToBase64String(arr);
return s3;
}
示例9: Response
string Response()
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
byte[] serverbuff = new byte[1024];
NetworkStream stream = GetStream();
int count = stream.Read(serverbuff, 0, 1024);
if (count == 0)
return "";
return enc.GetString(serverbuff, 0, count);
}
示例10: SetGetData
public void SetGetData()
{
string identifier = ProceduralDb.TempName();
var encoding = new System.Text.ASCIIEncoding();
const string testString = "This is a test";
var data = encoding.GetBytes(testString);
ProceduralDb.SetData(identifier, data);
data = ProceduralDb.GetData(identifier);
Assert.AreEqual(testString, encoding.GetString(data));
}
示例11: OnResponse
public override void OnResponse(ref HTTPRequestStruct request, ref HTTPResponseStruct response)
{
if (request.Method=="GET" && request.Args.ContainsKey("text"))
{
SpeechAgent.Notify(request.Args["text"].Replace("_"," "));
}
else if (request.Method=="POST")
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
string str = enc.GetString(request.BodyData);
SpeechAgent.Notify(str);
}
}
示例12: Chr
public static string Chr(int asciiCode)
{
if (asciiCode >= 0 && asciiCode <= 255)
{
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
byte[] byteArray = new byte[] { (byte)asciiCode };
string strCharacter = asciiEncoding.GetString(byteArray);
return (strCharacter);
}
else
{
throw new Exception("ASCII Code is not valid.");
}
}
示例13: Decode
public void Decode(System.Net.IPEndPoint remote_endpoint)
{
Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Connect(remote_endpoint);
NetworkStream stream = new NetworkStream(sock);
do
{
stream.Read(buffer, 0, buffer.Length);
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding ();
Console.Error.Write("{0}", encoding.GetString(buffer));
}
while (stream.DataAvailable);
}
示例14: Connect
private void Connect(string host, int port)
{
try {
cSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//cSocket.ReceiveTimeout = 15;
//cSocket.SendTimeout = 15;
cSocket.Connect (host, port);
if (cSocket.Connected == false) {
throw new Exception("Connected fail");
}
byte[] bigBuffer = new byte[24];
int receiveCount = 0;
//System.Threading.Thread.Sleep(5);
int BufferSize = 0;
do {
receiveCount = cSocket.Receive (bigBuffer);//, SocketFlags.None);
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
BufferSize = cSocket.Available;
Console.WriteLine ("ReadyForRead: " + BufferSize.ToString());
string result = enc.GetString(bigBuffer);
this.result += result;
//Console.WriteLine (result);
} while (receiveCount < BufferSize);
Console.WriteLine(this.result);
cSocket.Close();
} catch (Exception ex) {
Console.WriteLine (ex.ToString());
}
}
示例15: GetLatLngStatic
public static LatLng GetLatLngStatic(string addr, string city, int stateID, string key)
{
CurtDevDataContext db = new CurtDevDataContext();
// Get the state abbreviation that matches the stateID
string state_abbr = (from ps in db.PartStates
where ps.stateID.Equals(stateID)
select ps.abbr).FirstOrDefault<string>();
string url = "http://maps.google.com/maps/geo?output=csv&key=" + key + "&q=" + HttpContext.Current.Server.UrlEncode(addr + " " + city + ", " + state_abbr);
var request = WebRequest.Create(url);
var response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK) {
var ms = new MemoryStream();
var responseStream = response.GetResponseStream();
var buffer = new Byte[2048];
int count = responseStream.Read(buffer, 0, buffer.Length);
while (count > 0) {
ms.Write(buffer, 0, count);
count = responseStream.Read(buffer, 0, buffer.Length);
}
responseStream.Close();
ms.Close();
var responseBytes = ms.ToArray();
var encoding = new System.Text.ASCIIEncoding();
var coords = encoding.GetString(responseBytes);
var parts = coords.Split(',');
LatLng loc = new LatLng {
latitude = parts[2],
longitude = parts[3]
};
return loc;
}
return null;
}