System.Text.Encoding.GetEncoding(“iso-8859-1”) throws PlatformNotSupportedException?

前端 未结 5 1902
我在风中等你
我在风中等你 2020-12-15 22:28

See subject, note that this question only applies to the .NET compact framework. This happens on the emulators that ship with Windows Mobile 6 Professional

5条回答
  •  孤街浪徒
    2020-12-15 23:11

    If anyone is getting an exception(.NET compact framework) like:

     System.Text.Encoding.GetEncoding(“iso-8859-1”) throws PlatformNotSupportedException,
    
    //Please follow the steps: 
    
       byte[] bytes=Encoding.Default.GetBytes(yourText.ToString);
    
    //The code is:
    
        FileInfo fileInfo = new FileInfo(FullfileName); //file type :  *.text,*.xml 
        string yourText = (char) 0xA0 + @"¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
    
        using (FileStream s = fileInfo.OpenWrite()) {
                            s.Write(Encoding.Default.GetBytes(yourText.ToString()), 0, yourText.Length);
        }
    

提交回复
热议问题