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);
                    }
                }
  • 相关阅读:
    bzoj4423 [AMPPZ2013]Bytehattan
    bzoj3643 Phi的反函数
    hdu1024 Max Sum Plus Plus的另一种解法
    hdu1024 Max Sum Plus Plus
    bzoj3638 Cf172 k-Maximum Subsequence Sum
    bzoj3620 似乎在梦中见过的样子
    bzoj3667 Rabin-Miller算法
    bzoj3680 吊打XXX
    阿里Linux Shell脚本面试25个经典问答
    编程面试的10大算法概念汇总
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/1876884.html
Copyright © 2011-2022 走看看