久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 .net 中生成 UTF-8 字符集中的所有字符

How to Generate all the characters in the UTF-8 charset in .net(如何在 .net 中生成 UTF-8 字符集中的所有字符)
本文介紹了如何在 .net 中生成 UTF-8 字符集中的所有字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的任務是生成 UTF-8 字符集中的所有字符,以測試系統如何處理每個字符.我對字符編碼沒有太多經驗.我要嘗試的方法是增加一個計數器,然后嘗試將那個以十為基數的數字轉換為等效的 UTF-8 字符,但到目前為止,我還沒有在 C# 3.5 中找到一種有效的方法

I have been given the task of generating all the characters in the UTF-8 character set to test how a system handles each of them. I do not have much experience with character encoding. The approaching I was going to try was to increment a counter, and then try to translate that base ten number into it's equivalent UTF-8 character, but so far I have no been able to find an effective way to to this in C# 3.5

任何建議將不勝感激.

推薦答案

System.Net.WebClient client = new System.Net.WebClient();
string definedCodePoints = client.DownloadString(
                         "http://unicode.org/Public/UNIDATA/UnicodeData.txt");
System.IO.StringReader reader = new System.IO.StringReader(definedCodePoints);
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
while(true) {
  string line = reader.ReadLine();
  if(line == null) break;
  int codePoint = Convert.ToInt32(line.Substring(0, line.IndexOf(";")), 16);
  if(codePoint >= 0xD800 && codePoint <= 0xDFFF) {
    //surrogate boundary; not valid codePoint, but listed in the document
  } else {
    string utf16 = char.ConvertFromUtf32(codePoint);
    byte[] utf8 = encoder.GetBytes(utf16);
    //TODO: something with the UTF-8-encoded character
  }
}

上面的代碼應該遍歷當前分配的 Unicode 字符.您可能想要在本地解析 UnicodeData 文件并修復我遇到的任何 C# 錯誤制作.

The above code should iterate over the currently assigned Unicode characters. You'll probably want to parse the UnicodeData file locally and fix any C# blunders I've made.

當前分配的 Unicode 字符集小于可以定義的集.當然,當您打印出其中一個字符時,您是否看到一個字符取決于許多其他因素,例如字體和它在發送到您的眼球之前會通過的其他應用程序.

The set of currently assigned Unicode characters is less than the set that could be defined. Of course, whether you see a character when you print one of them out depends on a great many other factors, like fonts and the other applications it'll pass through before it is emitted to your eyeball.

這篇關于如何在 .net 中生成 UTF-8 字符集中的所有字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒有辦法知道是否有人為您的網站添加了書簽?)
Use of Different .Net Languages?(使用不同的 .Net 語言?)
Is there a C# library that will perform the Excel NORMINV function?(是否有執行 Excel NORMINV 函數的 C# 庫?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點的“活動用戶數)
Select x random elements from a weighted list in C# (without replacement)(從 C# 中的加權列表中選擇 x 個隨機元素(無需替換))
Best way to keep track of current online users(跟蹤當前在線用戶的最佳方式)
主站蜘蛛池模板: 91免费在线 | 午夜影院黄| 欧美成人第一页 | 日韩欧美亚洲 | 宅男噜噜噜66一区二区 | 91xh98hx 在线 国产 | 99免费在线观看视频 | 在线国产视频 | 在线看av网址 | 自拍亚洲 | www成年人视频 | 国产精品高潮呻吟久久 | 午夜视频在线观看网址 | 美女久久| 久久久国产视频 | 97人人草| 久久草视频 | 日韩黄色小视频 | 国产精品成人在线播放 | 国产成人免费视频网站高清观看视频 | 久久国产区 | 我爱操 | 激情av在线 | 精品伊人 | 亚洲视频免费 | 不卡的av电影 | 男人天堂手机在线视频 | 久久人体视频 | av看片网站| 一级电影免费看 | 一级欧美视频 | 亚洲美女视频 | 国产成人综合在线 | 日本一二三区高清 | 一区二区三区四区不卡视频 | 国产成人精品综合 | 国产成人a亚洲精品 | 日韩欧美在线视频 | 亚洲成人午夜电影 | 三级国产三级在线 | 国产精品高清在线 |