2011-02-17 48 views

回答

2

我能端口Mono的實施,.NET在不到一個小時。這是(最少?)組類需要移植(由依賴排序):

  1. I18N.Common.Strings
  2. I18N.Common.MonoEncoding
  3. I18N.CJK.CodeTable
  4. I18N.CJK.DbcsConvert
  5. I18N.CJK.DbcsEncoding
  6. I18N.CJK.JISConvert
  7. I18N.CJK.CP932

此外,以下文件需要被複制(裝載在I18N.CJK.CodeTable構造):

一個實現 「shift_jis訪問」 編碼是I18N.CJK.CP932的類。請注意,它必須手動實例化,不是Encoding.GetEncoding()

-1

我發現了一些信息在這裏:
http://www.eggheadcafe.com/community/aspnet/14/14621/covert-shiftjis-to-unicode.aspx

這是從上面(學分彼得布朗伯格)的鏈接是C#示例代碼。我無法確定它會在Silverlight中工作。我想這一切都取決於是否Encoding.GetEncoding(「SJIS」)是SL提供:

public class FileConverter 
{ 
    const int BufferSize = 8096; 

    public static void Main(string[] args) 
    { 
     if (args.Length != 2) 
     { 
      Console.WriteLine 
       ("Usage: FileConverter <input file> <output file>"); 
      return; 
     } 
     //NOTE: you may need to use " Encoding enc = Encoding.GetEncoding("shift-jis"); " for non-standard code pages 
     // Open a TextReader for the appropriate file 
     using (TextReader input = new StreamReader 
       (new FileStream (args[0], FileMode.Open), 
       Encoding.UTF8)) 
     { 
      // Open a TextWriter for the appropriate file 
      using (TextWriter output = new StreamWriter 
        (new FileStream (args[1], FileMode.Create), 
        Encoding.Unicode)) 
      { 

       // Create the buffer 
       char[] buffer = new char[BufferSize]; 
       int len; 

       // Repeatedly copy data until we've finished 
       while ((len = input.Read (buffer, 0, BufferSize)) > 0) 
       { 
        output.Write (buffer, 0, len); 
       } 
      } 
     } 
    } 
} 
+0

謝謝,但不,它不起作用,因爲Silverlight中沒有「shift-jis」編碼。顯然,Silverlight中只有UTF-8和UTF-16編碼可用。 – 2011-02-17 16:37:14

相關問題