• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Text.ASCIIEncoding类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Text.ASCIIEncoding的典型用法代码示例。如果您正苦于以下问题:C# System.Text.ASCIIEncoding类的具体用法?C# System.Text.ASCIIEncoding怎么用?C# System.Text.ASCIIEncoding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



System.Text.ASCIIEncoding类属于命名空间,在下文中一共展示了System.Text.ASCIIEncoding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:mydesignbuddy,项目名称:MugShot,代码行数:33,代码来源:ImageMedia.cs


示例2: Response

 private string Response()
 {
     System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
     byte[] serverbuff = new Byte[1024];
     NetworkStream stream = GetStream();
     int count = 0;
     while (true)
     {
         byte[] buff = new Byte[2];
         int bytes = stream.Read(buff, 0, 1);
         if (bytes == 1)
         {
             serverbuff[count] = buff[0];
             count++;
             if (buff[0] == '\n')
             {
                 break;
             }
         }
         else
         {
             break;
         }
     }
     string retval = enc.GetString(serverbuff, 0, count);
     return retval;
 }
开发者ID:chutinhha,项目名称:web-quan-ly-kho,代码行数:27,代码来源:POP3Auth.cs


示例3: 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;
 }
开发者ID:iamsamwood,项目名称:ENCODERS,代码行数:7,代码来源:Utility.cs


示例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");
 }
开发者ID:rossspoon,项目名称:bvcms,代码行数:26,代码来源:PostBundleController.cs


示例5: Encode

 public static string Encode(string value)
 {
     var hash = System.Security.Cryptography.SHA1.Create();
     var encoder = new System.Text.ASCIIEncoding();
     var combined = encoder.GetBytes(value ?? "");
     return BitConverter.ToString(hash.ComputeHash(combined)).ToLower().Replace("-", "");
 }
开发者ID:frintech,项目名称:KjGarments,代码行数:7,代码来源:Helper.cs


示例6: GetAuthorizationToken

        /// <summary>
        /// Function for getting a token from ACS using Application Service principal Id and Password.
        /// </summary>
        public static AADJWTToken GetAuthorizationToken(string tenantName, string appPrincipalId, string password)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format(StringConstants.AzureADSTSURL, tenantName));
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            string postData = "grant_type=client_credentials";            
            postData += "&resource=" + HttpUtility.UrlEncode(StringConstants.GraphPrincipalId);
            postData += "&client_id=" + HttpUtility.UrlEncode(appPrincipalId);
            postData += "&client_secret=" + HttpUtility.UrlEncode(password);
            byte[] data = encoding.GetBytes(postData);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }
            using (var response = request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(AADJWTToken));
                    AADJWTToken token = (AADJWTToken)(ser.ReadObject(stream));
                    return token;
                }
            }
        }
开发者ID:michaelsrichter,项目名称:AccidentalFish.AspNet.Identity.Azure,代码行数:30,代码来源:DirectoryDataServiceAuthorizationHelper.cs


示例7: Post

		public string Post(Uri uri, NameValueCollection input)
		{
			ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
			WebRequest request = WebRequest.Create(uri);
			string strInput = GetInputString(input);
			
			request.Method = "POST";
			request.ContentType = "application/x-www-form-urlencoded";
			request.ContentLength = strInput.Length;
			
			Stream writeStream = request.GetRequestStream();
			System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
			byte[] bytes = encoding.GetBytes(strInput);
			writeStream.Write(bytes, 0, bytes.Length);
			writeStream.Close();

            using (WebResponse response = request.GetResponse())
            {
                using (Stream responseStream = response.GetResponseStream())
                {
                    StreamReader streamReader = new StreamReader(responseStream);
                    return streamReader.ReadToEnd();
                }
            }
		}
开发者ID:BiYiTuan,项目名称:CruiseControl.NET,代码行数:25,代码来源:WebRetriever.cs


示例8: Encrypt

        /// <summary>
        /// 指定されたUIDを暗号化して返します。
        /// </summary>
        /// <param name="uid">MUID</param>
        /// <returns></returns>
        public static string Encrypt(string uid)
        {
            var encryptStr = "";
            if (!string.IsNullOrEmpty(uid))
            {
                if (CheckMuid(uid))
                {
                    uid = uid.Replace(".", "");
                    if(uid.Length%2!=0)
                    {
                        uid = uid + "0";
                    }
                    var asciiEncoding = new System.Text.ASCIIEncoding();

                    for (int i = 0; i < uid.Length / 2; i++)
                    {
                        var subUid = uid.Substring(i * 2, 2);
                        encryptStr = encryptStr + subUid + ((asciiEncoding.GetBytes(uid.Substring(i * 2, 1))[0] + asciiEncoding.GetBytes(uid.Substring(i * 2 + 1, 1))[0]) % 15).ToString("x");
                    }
                    char[] arr = encryptStr.ToCharArray();
                    Array.Reverse(arr);
                    encryptStr = new string(arr);
                }
                else
                {
                    encryptStr = "00000";
                }
            }
            else
            {
                encryptStr = "00000";
            }
            return encryptStr;
        }
开发者ID:BGCX261,项目名称:zmw-dev-svn-to-git,代码行数:39,代码来源:EncryptUidUtils.cs


示例9: ByteArrayToStr

 public static string ByteArrayToStr(byte[] dBytes)
 {
     string str;
     System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
     str = enc.GetString(dBytes);
     return str;
 }
开发者ID:zaeem,项目名称:FlexCollab,代码行数:7,代码来源:InviteForm.cs


示例10: 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);
        }
开发者ID:johanburati,项目名称:stuff,代码行数:25,代码来源:renexif.cs


示例11: GetCurrentAirInstall

        public string GetCurrentAirInstall(string Location)
        {
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            DirectoryInfo dInfo = new DirectoryInfo(Location);
            DirectoryInfo[] subdirs = null;
            try
            {
                subdirs = dInfo.GetDirectories();
            }
            catch { return "0.0.0.0"; }
            string latestVersion = "0.0.1";
            foreach (DirectoryInfo info in subdirs)
            {
                latestVersion = info.Name;
            }

            string AirLocation = Path.Combine(Location, latestVersion, "deploy");
            if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat")))
            {
                File.Copy(Path.Combine(AirLocation, "lib", "ClientLibCommon.dat"), Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"));
            }
            if (!File.Exists(Path.Combine(Client.ExecutingDirectory, "gameStats_en_US.sqlite")))
            {
                File.Copy(Path.Combine(AirLocation, "assets", "data", "gameStats", "gameStats_en_US.sqlite"), Path.Combine(Client.ExecutingDirectory, "gameStats_en_US.sqlite"));
            }

            Copy(Path.Combine(AirLocation, "assets", "images", "abilities"), Path.Combine(Client.ExecutingDirectory, "Assets", "abilities"));
            Copy(Path.Combine(AirLocation, "assets", "images", "champions"), Path.Combine(Client.ExecutingDirectory, "Assets", "champions"));

            var VersionAIR = File.Create(Path.Combine("Assets", "VERSION_AIR"));
            VersionAIR.Write(encoding.GetBytes(latestVersion), 0, encoding.GetBytes(latestVersion).Length);
            VersionAIR.Close();
            return latestVersion;
        }
开发者ID:JizzHub,项目名称:LegendaryClient,代码行数:34,代码来源:RiotPatcher.cs


示例12: Main

        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\umundo\\lib");
            org.umundo.core.Node node = new org.umundo.core.Node();
            Publisher pub = new Publisher("pingpong");
            PingReceiver recv = new PingReceiver();
            Subscriber sub = new Subscriber("pingpong", recv);
            node.addPublisher(pub);
            node.addSubscriber(sub);

            while (true)
            {
                Message msg = new Message();
                String data = "data";
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                byte[] buffer = enc.GetBytes(data);
                msg.setData(buffer);
                msg.putMeta("foo", "bar");
                Console.Write("o");
                pub.send(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
开发者ID:0790486,项目名称:umundo,代码行数:26,代码来源:Program.cs


示例13: 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 ();
        }
开发者ID:hacxman,项目名称:zeroshare,代码行数:35,代码来源:StdinContentEncoder.cs


示例14: CutString

 /// <summary>
 /// 截取指定长度字符串,汉字为2个字符
 /// </summary>
 /// <param name="inputString">要截取的目标字符串</param>
 /// <param name="len">截取长度</param>
 /// <returns>截取后的字符串</returns>
 public static string CutString(string inputString, int len)
 {
     System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
     int tempLen = 0;
     string tempString = "";
     byte[] s = ascii.GetBytes(inputString);
     for (int i = 0; i < s.Length; i++)
     {
         if ((int)s[i] == 63)
             tempLen += 2;
         else
             tempLen += 1;
         try
         {
             tempString += inputString.Substring(i, 1);
         }
         catch
         {
             break;
         }
         if (tempLen > len)
             break;
     }
     return tempString;
 }
开发者ID:joyhen,项目名称:mywork,代码行数:31,代码来源:StringHelp.cs


示例15: GetCurrentGameInstall

        public string GetCurrentGameInstall(string GameLocation)
        {
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            DirectoryInfo dInfo = new DirectoryInfo(Path.Combine(GameLocation, "projects", "lol_game_client", "filearchives"));
            DirectoryInfo[] subdirs = null;
            try
            {
                subdirs = dInfo.GetDirectories();
            }
            catch { return "0.0.0.0"; }
            string latestVersion = "0.0.1";
            foreach (DirectoryInfo info in subdirs)
            {
                latestVersion = info.Name;
            }

            string ParentDirectory = Directory.GetParent(GameLocation).FullName;
            Copy(Path.Combine(ParentDirectory, "Config"), Path.Combine(Client.ExecutingDirectory, "Config"));

            Copy(Path.Combine(GameLocation, "projects", "lol_game_client"), Path.Combine(Client.ExecutingDirectory, "RADS", "projects", "lol_game_client"));
            File.Copy(Path.Combine(GameLocation, "RiotRadsIO.dll"), Path.Combine(Client.ExecutingDirectory, "RADS", "RiotRadsIO.dll"));

            var VersionAIR = File.Create(Path.Combine("RADS", "VERSION_LOL"));
            VersionAIR.Write(encoding.GetBytes(latestVersion), 0, encoding.GetBytes(latestVersion).Length);
            VersionAIR.Close();
            return latestVersion;
        }
开发者ID:JizzHub,项目名称:LegendaryClient,代码行数:27,代码来源:RiotPatcher.cs


示例16: 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;
        }
开发者ID:physion,项目名称:symphony-core,代码行数:25,代码来源:ErrorDescription.cs


示例17: CheckMuid

        /// <summary>
        /// Uidチェック(0~9|a~z|A~Z)かつ18桁
        /// </summary>
        /// <param name="uid">UID</param>
        /// <returns></returns>
        private static bool CheckMuid(string uid)
        {
            var asciiEncoding = new System.Text.ASCIIEncoding();

            var rst = uid.Select((t, i) => (int)asciiEncoding.GetBytes(uid.Substring(i, 1))[0]).Aggregate(true, (current, z) => current && ((47 < z && z < 58) || (64 < z && z < 91) || (96 < z && z < 123) || z==46));
            return  rst;
        }
开发者ID:BGCX261,项目名称:zmw-dev-svn-to-git,代码行数:12,代码来源:EncryptUidUtils.cs


示例18: sendmessage

        public static bool sendmessage(MessageTypes type, string msg, ref byte[] data)
        {
            try
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                byte[] message = encoding.GetBytes(msg);
                int size = HEADERSIZE + message.Length;
                data = new byte[size];
                byte[] sizebyte = BitConverter.GetBytes(size);
                byte[] typebyte = BitConverter.GetBytes((int)type);
                Array.Copy(sizebyte, 0, data, LENGTHOFFSET, sizebyte.Length);
                Array.Copy(typebyte, 0, data, TYPEOFFSET, typebyte.Length);
                Array.Copy(message, 0, data, HEADERSIZE, message.Length);
            }
#if DEBUG
            catch (Exception ex)
            {
                Console.WriteLine("error processing: " + type.ToString() + " msg: " + msg + " err: " + ex.Message + ex.StackTrace);
                return false;
            }
#else
            catch (Exception)
            {
            }
#endif

            return true;

            
        }
开发者ID:bluejack2000,项目名称:core,代码行数:30,代码来源:Message.cs


示例19: StringToByteArray

        /// <summary>
        /// Convert string to a byte array.
        /// </summary>
        /// <param name="text">String to convert.</param>
        /// <returns>Byte array. null if text is null, and empty array if
        /// the string is empty.
        ///</returns>
        public static byte[] StringToByteArray(string text)
        {
            if (text == null)
                return null;

            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            return encoding.GetBytes(text);
        }
开发者ID:erdincay,项目名称:checksum-tool,代码行数:15,代码来源:StringUtil.cs


示例20: WriteData

 private void WriteData(Stream requestStream, string data)
 {
     System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
     byte[] dataAsBytes = encoding.GetBytes(data);
     Stream dataStream = requestStream;
     dataStream.Write(dataAsBytes, 0, dataAsBytes.Length);
     dataStream.Close();
 }
开发者ID:BenHall,项目名称:Loft,代码行数:8,代码来源:JsonRequester.cs



注:本文中的System.Text.ASCIIEncoding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Text.Encoding类代码示例发布时间:2022-05-24
下一篇:
C# System.String类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap