2
http://expert.csdn.net/Expert/topic/2872/2872552.xml?temp=.2827112

解决方案 »

  1.   

    gb18030是先行汉字编码的强制标准。所有用到汉字编码的地方目前都必须符合gb18030
      

  2.   

    c#中将类序列化为XML文件时,默认的字符编码是UTF-8,
    但中文也没有任何问题啊。
    下面是我序列化的代码。//////////////////////////
    //ApplicationSettings是我的类,有string类成员若干,我给它们一些值(中文字符串)
    //
    ////////////////////////////public bool SaveAppSettings()
    {
    if(this.appSettingsChanged)
    {
    StreamWriter myWriter = null;
    XmlSerializer mySerializer = null;
    try
    {
    // 为 ApplicationSettings 类型
    // 创建 XmlSerializer。
    mySerializer = new XmlSerializer(typeof(ApplicationSettings));
    myWriter = new StreamWriter(@"c:\myApplication.config",false);
    // 将 ApplicationSettings 类的这一实例
    // 序列化到配置文件中。
    mySerializer.Serialize(myWriter, this);
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message); 
    }
    finally
    {
    // 如果 FileStream 是打开的,将其关闭。
    if(myWriter != null)
    {
    myWriter.Close();
    }
    }
    }
    return appSettingsChanged;
    }序列化后生成的xml文件:<?xml version="1.0" encoding="utf-8"?>
    <ApplicationSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <textbox1>大家好</textbox1>
      <textbox2>我是XXX</textbox2>
      <textbox3>呵呵</textbox3>
    </ApplicationSettings>
      

  3.   

    1.encoding="gb2312";
    2.http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=4723
      

  4.   

    to: Dugu_Niu(有痔青年)我这样写时,里面有中文就不能正常显示了,为什么呀?
    其中ourTeam 是一个类的实例,基中包括一些中文信息。
    private void btnSerial_Click(object sender, System.EventArgs e)
    {

    try
    {
    XmlSerializer theSerial=new XmlSerializer(typeof(OurTeam));
    sw=new StreamWriter("Employee.xml",false);
    theSerial.Serialize(sw,ourTeam);
    MessageBox.Show("Yes,everything has been done!");
    }
    catch (Exception excep)
    {
    MessageBox.Show(excep.Message);
    }
    finally
    {
    sw.Flush();
    sw.Close();
    ourTeam.Clear();
    }
    }
    运行程序后结果XML文件显示如下:<?xml version="1.0" encoding="utf-8"?>
    <ArrayOfEmployee xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Employee>
        <Fname>liubin</Fname>
        <Lname>bill</Lname>
        <Title>boss</Title>
      </Employee>
      <Employee>
        <Fname>kingcal</Fname>
        <Lname>chen</Lname>
        <Title>staff</Title>
      </Employee>
      <Employee>
        <Fname>chen</Fname>
        <Lname>xiaoquan</Lname>
        <Title>secretary</Title>
      </Employee>
      <Employee>
        <Fname>鍒?/Fname>
        <Lname>瀹?/Lname>
        <Title>澶寸洰</Title>
      </Employee>
    </ArrayOfEmployee>
      

  5.   

    第二个问题偶会using System.Text.RegularExpressions;Regex.IsMatch(string1, string2);
    string1是原始字符串,string2是要匹配的字符,结果是一个bool。
      

  6.   

    to: mobydick(敌伯威) 
    要匹配的字符不是具体的呀,比如我要匹配‘ma’与 ‘na’之间的所有字符,包括中文字符
    该怎么做?