Silverlight GB2312

Silverlight 中默認是不支持GB2312的,需要第三方庫支持 

http://gb2312.codeplex.com/ 


Project Description
This class is for support GB2312 simplified Chinese characters for Silverlight(include Windows Phone 7) Application and inherited from Encoding abstract class. It's developed in CSharp.

這個類能夠讓 Silverlight(包含 Windows Phone 7)應用程序支持 GB2312 簡體中文字符集,從 Encoding 抽象類繼承。使用 C# 語言編寫。


GB2312Encoding is fully implemented all Encoding functions therefore you can uses it as easy as system built-in Encoding features. In order to use the GB2312Encoding, you must embed an addition data file in your assembly.
Following features has been implemented:

  • Immediate decode array bytes and encode string or array chars
  • Simple use StreamReader and StreamWriter read and write stream

GB2312Encoding 類完整的實現了 Encoding 的所有功能,因此你可以很容易的實現所有的字符集編碼功能。爲了使用 GB2312Encoding,你必須嵌入一個附加的數據文件到你的程序集。
本程序實現了下列功能:
  • 解碼字節數組和編碼字符串或字符數組
  • 使用 StreamReader 和 StreamWriter 對流進行讀寫操作

Sample(例子):

WebClient _wc = new WebClient();
_wc.Encoding = new GB2312.GB2312Encoding();
_wc.DownloadStringCompleted += (ss, ee) => txtResult.Text = ee.Result;
_wc.DownloadStringAsync(new Uri(txtUrl.Text));


How to use:

Copy GB2312Encoding.cs and gb2312.bin files into your project and make sure:
  • gb2312.bin file’s build action is “Embedded Resource”
  • gb2312.bin filename correct(cannot modify filename)
  • GB2312Encoding.cs and gb2312.bin files in same folder

如何使用:

把 GB2312Encoding.cs 和 gb2312.bin 文件複製到你的項目並確保
  • gb2312.bin 文件的生成操作是“嵌入的資源”
  • gb2312.bin 文件的文件名正確(不能修改此文件名)
  • GB2312Encoding.cs 和 gb2312.bin 文件在同一個文件夾

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章