当前位置: 首页>>代码示例>>C#>>正文


C# Text.UTF32Encoding类代码示例

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


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

示例1: EncodingDetecingInputStream

		static EncodingDetecingInputStream ()
		{
			StrictUTF8 = new UTF8Encoding (false, true);
			Strict1234UTF32 = new UTF32Encoding (true, false, true);
			StrictBigEndianUTF16 = new UnicodeEncoding (true, false, true);
			StrictUTF16 = new UnicodeEncoding (false, false, true);
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:JsonReader.cs

示例2: GetUtf32

 public static string GetUtf32(string unicodeString)
 {
     var utf8 = new UTF32Encoding();
     byte[] encodeBytes = utf8.GetBytes(unicodeString);
     string decodedString = utf8.GetString(encodeBytes);
     return decodedString;
 }
开发者ID:mnt777,项目名称:MineStocks,代码行数:7,代码来源:Utility.cs

示例3: StflApi

        static StflApi()
        {
            // check if he has a graphical terminal. screen/tmux in not
            // detected in case someone is using it in pure text mode
            string termName = Environment.GetEnvironmentVariable("TERM");
            IsXterm = (termName != null && (termName.StartsWith("xterm") ||
                termName.StartsWith("rxvt")));
            // detect UTF-8 locale according to:
            // http://www.cl.cam.ac.uk/~mgk25/unicode.html#activate
            var locale = Environment.GetEnvironmentVariable("LC_ALL") ??
                         Environment.GetEnvironmentVariable("LC_LCTYPE") ??
                         Environment.GetEnvironmentVariable("LANG") ??
                         String.Empty;
            locale = locale.ToUpperInvariant();
            IsUtf8Locale = locale.Contains("UTF-8") || locale.Contains("UTF8");

            EscapeLessThanCharacter = "<>";
            EscapeGreaterThanCharacter = ">";

            Utf32NativeEndian = new UTF32Encoding(
                bigEndian: !BitConverter.IsLittleEndian,
                byteOrderMark: false,
                throwOnInvalidCharacters: true
            );

            // UTF-32 handling is broken in mono < 4.2
            // fix in 4.4: https://github.com/mono/mono/commit/6bfb7e6d149f5e5c0fe04d680e3f7d36769ef541
            // fix in 4.2: https://github.com/mono/mono/commit/ea4ed4a47b98832e294d166bee5b8301fe87e216
            BrokenUtf32Handling = IsMonoVersionLessThan(4, 2);
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:30,代码来源:StflApi.cs

示例4: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
            UTF32Encoding utf8 = new UTF32Encoding();
            string hashResult = BitConverter.ToString(sha1.ComputeHash(utf8.GetBytes(textBox2.Text)));

            label4.Text = hashResult;
            label3.Text = hashResult.Length.ToString();
        }
开发者ID:TheSniper102,项目名称:winformsTuts,代码行数:9,代码来源:Hashing.cs

示例5: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            UTF32Encoding utf8 = new UTF32Encoding();
            string hashResult = BitConverter.ToString(md5.ComputeHash(utf8.GetBytes(textBox1.Text)));

            label1.Text = hashResult;
            label2.Text = hashResult.Length.ToString();
        }
开发者ID:TheSniper102,项目名称:winformsTuts,代码行数:9,代码来源:Hashing.cs

示例6: Md5Encrypte

        public static string Md5Encrypte(string inputString)
        {
            var u = new System.Text.UTF32Encoding();
            byte[] bytes = u.GetBytes(inputString);
            System.Security.Cryptography.MD5 md = new System.Security.Cryptography.MD5CryptoServiceProvider();

            byte[] result = md.ComputeHash(bytes);
            return Convert.ToBase64String(result);
        }
开发者ID:nstungxd,项目名称:ips-project-vdc,代码行数:9,代码来源:Common.cs

示例7: FromString

		/// <summary>hashing from string. Result in format of 000-000</summary>
		public static string FromString(string input)
		{
			if (input.IsNullOrEmpty())
				return FromBuffer(null);


			var utf32 = new UTF32Encoding();
			return FromBuffer(utf32.GetBytes(input));
		}
开发者ID:cssack,项目名称:CsGlobals,代码行数:10,代码来源:SmallHash.cs

示例8: CreateHash

        /// <summary>
        /// Creates a password hash from the details provided
        /// </summary>
        /// <param name="created">The time when the person was created</param>
        /// <param name="password">The desired password</param>
        /// <param name="salt">The login's salt</param>
        /// <returns>A Byte[] with the password hash</returns>
        public Byte[] CreateHash(DateTime created, string password, string salt)
        {
            if (password == null) throw new ArgumentNullException("password");
            if (salt == null) throw new ArgumentNullException("salt");

            SHA1 sha = new SHA1CryptoServiceProvider();
            UTF32Encoding enc = new UTF32Encoding();
            var stringValue = string.Concat(_configurationManager.HashConstant, created, password, salt);
            return sha.ComputeHash(enc.GetBytes(stringValue));
        }
开发者ID:ardliath,项目名称:BigSpace,代码行数:17,代码来源:CryptographyManager.cs

示例9: GetByteCount2

		[Category ("NotDotNet")] // A1/B1 return 24 on MS
		public void GetByteCount2 ()
		{
			string s = "za\u0306\u01FD\u03B2\uD8FF\uDCFF";

			UTF32Encoding le = new UTF32Encoding (false, true);
			Assert.AreEqual (28, le.GetByteCount (s), "#A1");
			Assert.AreEqual (0, le.GetByteCount (string.Empty), "#A2");

			UTF32Encoding be = new UTF32Encoding (true, true);
			Assert.AreEqual (28, be.GetByteCount (s), "#B1");
			Assert.AreEqual (0, be.GetByteCount (string.Empty), "#B2");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:13,代码来源:UTF32EncodingTest.cs

示例10: GetByteCount1

		[Category ("NotDotNet")] // A1/B1 return 24 on MS
		public void GetByteCount1 ()
		{
			char [] chars = new char[] { 'z', 'a', '\u0306',
				'\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };

			UTF32Encoding le = new UTF32Encoding (false, true);
			Assert.AreEqual (28, le.GetByteCount (chars), "#A1");
			Assert.AreEqual (0, le.GetByteCount (new char [0]), "#A2");

			UTF32Encoding be = new UTF32Encoding (true, true);
			Assert.AreEqual (28, be.GetByteCount (chars), "#B1");
			Assert.AreEqual (0, be.GetByteCount (new char [0]), "#B2");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:14,代码来源:UTF32EncodingTest.cs

示例11: GetByteCount

		[Test] // GetByteCount (String)
		public void GetByteCount2_S_Null ()
		{
			UTF32Encoding enc = new UTF32Encoding ();
			try {
				enc.GetByteCount ((string) null);
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.AreEqual ("s", ex.ParamName, "#5");
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:14,代码来源:UTF32EncodingTest.cs

示例12: OpensReaderWithoutAutoDetectEncoding

        public void OpensReaderWithoutAutoDetectEncoding()
        {
            string expected = "test";
            Encoding utf32 = new UTF32Encoding(false, true);
            byte[] resourceData = GetBytes(expected, utf32);
            EncodedResource r = new EncodedResource(new InputStreamResource(new MemoryStream(resourceData), "description"), Encoding.UTF8, false);
            StreamReader reader = (StreamReader)r.OpenReader();
            Assert.AreEqual(Encoding.UTF8.EncodingName, reader.CurrentEncoding.EncodingName);
            string actual = reader.ReadToEnd();
//            Assert.AreEqual("\uFFFD\uFFFD\0\0t\0\0\0e\0\0\0s\0\0\0t\0\0\0", actual);
            Assert.AreEqual(Encoding.UTF8.GetString(resourceData), actual);
            Assert.AreEqual(Encoding.UTF8.EncodingName, reader.CurrentEncoding.EncodingName);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:13,代码来源:EncodedResourceTests.cs

示例13: OpensReaderWithAutoDetectEncoding

        public void OpensReaderWithAutoDetectEncoding()
        {
            string expected = "test";
            Encoding utf32 = new UTF32Encoding(false, true);
            byte[] resourceData = GetBytes(expected, utf32);
            resourceData = (byte[])ArrayUtils.Concat(utf32.GetPreamble(), resourceData);
            EncodedResource r = new EncodedResource( new InputStreamResource( new MemoryStream( resourceData), "description" ), Encoding.UTF8, true);
            StreamReader reader = (StreamReader)r.OpenReader();
            Assert.AreEqual(Encoding.UTF8.EncodingName, reader.CurrentEncoding.EncodingName);
            string actual = reader.ReadToEnd();
            Assert.AreEqual( "\uFEFF" + expected , actual);
// interestingly the line below is *not* true!
//            Assert.AreEqual(utf32.GetString(resourceData), actual);
            Assert.AreEqual(utf32, reader.CurrentEncoding);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:15,代码来源:EncodedResourceTests.cs

示例14: ComputeSaltedHash

        /// <summary>
        /// Compute the salted hash of the given password
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public string ComputeSaltedHash(string password)
        {
            if (password == null)
                throw new ArgumentNullException("password");

            //Encoder for password (text->bytes)
            UTF32Encoding encoder = new UTF32Encoding();

            //Put password bytes and then saly bytes into byte array
            var toHash = encoder.GetBytes(password)
                .Concat(BitConverter.GetBytes(Salt))
                .ToArray();

            // Hash the salted password
            using (SHA512Managed sha1 = new SHA512Managed())
                return BitConverter.ToString(sha1.ComputeHash(toHash)).Replace("-", "");
        }
开发者ID:WildGenie,项目名称:Bastet-Legacy,代码行数:22,代码来源:User.cs

示例15: DefineEncoding

        private static Encoding DefineEncoding(Encoding enc, FileStream fs)
        {
            int bytesPerSignature = 0;
            byte[] signature = new byte[4];
            int c = fs.Read(signature, 0, 4);
            if (signature[0] == 0xFF && signature[1] == 0xFE && signature[2] == 0x00 && signature[3] == 0x00 && c >= 4)
            {
                enc = Encoding.UTF32;//UTF32 LE
                bytesPerSignature = 4;
            }
            else
            if (signature[0] == 0x00 && signature[1] == 0x00 && signature[2] == 0xFE && signature[3] == 0xFF)
            {
                enc = new UTF32Encoding(true, true);//UTF32 BE
                bytesPerSignature = 4;
            }
            else
            if (signature[0] == 0xEF && signature[1] == 0xBB && signature[2] == 0xBF)
            {
                enc = Encoding.UTF8;//UTF8
                bytesPerSignature = 3;
            }
            else
            if (signature[0] == 0xFE && signature[1] == 0xFF)
            {
                enc = Encoding.BigEndianUnicode;//UTF16 BE
                bytesPerSignature = 2;
            }
            else
            if (signature[0] == 0xFF && signature[1] == 0xFE)
            {
                enc = Encoding.Unicode;//UTF16 LE
                bytesPerSignature = 2;
            }

            fs.Seek(bytesPerSignature, SeekOrigin.Begin);

            return enc;
        }
开发者ID:WendyH,项目名称:HMSEditor_addon,代码行数:39,代码来源:FileTextSource.cs


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