asp.net讀取Mysql資料庫亂碼的問題解決方案

來源:互聯網
上載者:User
在下面的映射表中加入gb2312 和gbk,就不會有亂碼了,源碼在下面提供
一位網友寫的程式改了改

private static void LoadCharsetMap()
        {
            mapping = new Hashtable();

            mapping.Add( "big5", "big5" );        // Traditional Chinese
            mapping.Add( "sjis", "sjis" );        // Shift-JIS
            mapping.Add( "gb2312", "gb2312" );
            mapping.Add( "latin1", "latin1" );
            mapping.Add( "latin2", "latin2" );
            mapping.Add( "latin3", "latin3" );
            mapping.Add( "latin4", "latin4" );
            mapping.Add( "latin5", "latin5" );
            mapping.Add( "greek", "greek" );
            mapping.Add( "hebrew", "hebrew" );
            mapping.Add( "utf8", "utf-8" );
            mapping.Add( "ucs2", "UTF-16BE" );
            mapping.Add( "cp1251", 1251 );
            mapping.Add( "tis620", 874 );
            mapping.Add( "binary", "latin1" );

            // relatively sure about
/**//*            mapping.Add( "default", 0 );
            mapping.Add( "cp1251", 1251 );        // Russian
            mapping.Add( "win1251", 1251 );
            mapping.Add( "gbk", 936 );            // Simplified Chinese
            mapping.Add( "cp866", 866 );
            mapping.Add( "euc_kr", 949 );

            // maybe, maybe not
            mapping.Add( "win1250", 1250 );        // Central Eurpoe
            mapping.Add( "win1251ukr", 1251 );
            mapping.Add( "latin1_de", 1252 );    // Latin1 German
            mapping.Add( "german1", 1252 );        // German
            mapping.Add( "danish", 1252 );        // Danish
            mapping.Add( "dos", 437 );            // Dos
            mapping.Add( "pclatin2", 852 );        
            mapping.Add( "win1250ch", 1250 );
            mapping.Add( "cp1257", 1257 );
            mapping.Add( "usa7", 646 );
            mapping.Add( "czech", 912 );
            mapping.Add( "hungarian", 912 );
            mapping.Add( "croat", 912 ); */

            /**//*            ("gb2312", "EUC_CN");
                        ("ujis", "EUC_JP");
                        ("latvian", "ISO8859_13");
                        ("latvian1", "ISO8859_13");
                        ("estonia", "ISO8859_13");
                        ("koi8_ru", "KOI8_R");
                        ("tis620", "TIS620");
                        ("macroman", "MacRoman");
                        ("macce", "MacCentralEurope");
            */

        }

源碼:http://files.cnblogs.com/goody9807/mysql_src.rar

http://files.cnblogs.com/goody9807/mysql_src.rar

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.