zoukankan      html  css  js  c++  java
  • 字符集的问题

    AX中的字符型字段用的是NVchar类型,编码是Unicode,这是通用的编码方式,支持多国语言字符的数据。但是如果要将AX里的数据导出到不支持Unicode的系统中就有些麻烦了,用SSIS的简体中文字符集导出时如果遇到简体中文字符集不支持的字符它就会报错了。用如下代码可以找到简体中文不支持的字符。

    代码
    SqlCommand sqlCommand = new SqlCommand("select nameAlias from InventTable", sqlConnection);
                SqlDataReader dataReader 
    = sqlCommand.ExecuteReader();
                
    while (dataReader.Read())
                {
                    
    string nameAlias = dataReader.GetValue(0).ToString();
                    
    byte[] gb2312 = System.Text.Encoding.Convert(System.Text.Encoding.Unicode, System.Text.Encoding.GetEncoding("GB2312"), System.Text.Encoding.Unicode.GetBytes(nameAlias));
                    
    char[] gb2312Char = new char[System.Text.Encoding.GetEncoding("GB2312").GetCharCount(gb2312, 0, gb2312.Length)];
                    System.Text.Encoding.GetEncoding(
    "GB2312").GetChars(gb2312, 0, gb2312.Length, gb2312Char,0);
                    
    string gb2312String = new string(gb2312Char);
                    
                    
    if (nameAlias != gb2312String)
                    {
                        Console.WriteLine(nameAlias);
                        Console.WriteLine(gb2312String);
                    }
                }
  • 相关阅读:
    php xdebug的配置、调试、跟踪、调优、分析
    alpine使用的避坑指南
    nginx fastcgi模块ngx_http_fastcgi_module详细解析、使用手册、完整翻译
    深入理解 Kubernetes 资源限制:CPU
    使用xdebug对php做性能分析调优
    alpine安装sshd/ssh server
    冒泡排序的终极改进优化
    基于Maven的Springboot+Mybatis+Druid+Swagger2+mybatis-generator框架环境搭建
    NPM使用
    NodeJS学习历程
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/1876884.html
Copyright © 2011-2022 走看看