zoukankan      html  css  js  c++  java
  • .net操作mysql中文字符乱码的问题

    //写入数据库时进行转换
            public string GB2312_ISO8859(string write)
            {
                //声明字符集
                System.Text.Encoding iso8859, gb2312;
                //iso8859
                iso8859 = System.Text.Encoding.GetEncoding("iso8859-1");
                //国标2312
                gb2312 = System.Text.Encoding.GetEncoding("gb2312");
                byte[] gb;
                gb = gb2312.GetBytes(write);
                //返回转换后的字符
                return iso8859.GetString(gb);
            }

            //读出时进行转换
            public string ISO8859_GB2312(string read)
            {
                //声明字符集
                System.Text.Encoding iso8859, gb2312;
                //iso8859
                iso8859 = System.Text.Encoding.GetEncoding("iso8859-1");
                //国标2312
                gb2312 = System.Text.Encoding.GetEncoding("gb2312");
                byte[] iso;
                iso = iso8859.GetBytes(read);
                //返回转换后的字符
                return gb2312.GetString(iso);
            }

            //批量数据转换
            //其实就是将dataset的内容读出到xml文件,然后再输出
            public DataSet ISO8859_GB2312(DataSet ds)
            {
                string xml;
                xml = ds.GetXml();
                ds.Clear();
                //声明字符集
                System.Text.Encoding iso8859, gb2312;
                //iso8859
                iso8859 = System.Text.Encoding.GetEncoding("iso8859-1");
                //国标2312
                gb2312 = System.Text.Encoding.GetEncoding("gb2312");
                byte[] bt;
                bt = iso8859.GetBytes(xml);
                xml = gb2312.GetString(bt);
                ds.ReadXml(new System.IO.StringReader(xml));
                return ds;
            }

  • 相关阅读:
    xml的servlet配置
    python Matplotlib 系列教程(三)——绘制直方图和条形图
    https://blog.csdn.net/blmoistawinde/article/details/84329103
    机器学习——标准化/归一化的目的、作用和场景
    梯度提升决策树(GBDT)与XGBoost、LightGBM
    最容易理解的对卷积(convolution)的解释
    如何通俗易懂地解释卷积?
    卷积神经网络(CNN)之一维卷积、二维卷积、三维卷积详解
    Conv1D和Conv2D的区别
    卷积神经网络(CNN)张量(图像)的尺寸和参数计算(深度学习)
  • 原文地址:https://www.cnblogs.com/im/p/1151309.html
Copyright © 2011-2022 走看看