Jelajahi Sumber

UTF32处理字符串

黄贺彬 4 tahun lalu
induk
melakukan
a29decc9fc
1 mengubah file dengan 6 tambahan dan 27 penghapusan
  1. 6 27
      HTEXTest/Program.cs

+ 6 - 27
HTEXTest/Program.cs

@@ -7,6 +7,7 @@ using HTEXLib.Models;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Text;
 using System.Text.Json;
 using System.Text.Json;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 
 
@@ -17,36 +18,14 @@ namespace HTEXTest
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
             string a = "𝐿𝑀是㇀𝑁A𝑂Bcd𝑃𝑥𝑦𝑧";
             string a = "𝐿𝑀是㇀𝑁A𝑂Bcd𝑃𝑥𝑦𝑧";
-            string[] sArray = Regex.Split(a, "", RegexOptions.IgnoreCase);
-            string unicode = "";
-            string result = "";
-            string reg = "\\s*";
-            char[] aaaa = a.ToCharArray();
-            foreach (char bb in aaaa) {
-                Console.WriteLine((int)bb);
-            }
-            List<string> list = new List<string>();
-            for (int i = 0; i < sArray.Length; i++) {
-                //\ud835
-                string s = sArray[i] ;
-                if (s.ToString().Contains("\\")) {
-                    Console.WriteLine("aaa");
-                }
-                if (s.ToString().Length>1)
-                {
-                    string aa   = sArray[i] + sArray[i + 1];
-                    list.Add(aa);
-                    i = i + 1;
-                }
-                else {
-                    list.Add(s);
-                }
-
-            }
+            UTF32Encoding encoding = new UTF32Encoding();
+            Byte[] encodedBytes = encoding.GetBytes(a);
+            string ad =  encoding.GetString(encodedBytes, 0, 4);
+          
             
             
             
             
              
              
-            char [] chas =a.ToCharArray();
+           
             //var a = CharHelper.chararry;
             //var a = CharHelper.chararry;
             // Dictionary<string, string> ditc = new Dictionary<string, string>();
             // Dictionary<string, string> ditc = new Dictionary<string, string>();
             // foreach (var aa in a) {
             // foreach (var aa in a) {