2010年1月29日 星期五

關於 asSQL 顯示中文的問題

昨天玩了一下 Flex AIR , 使用 asSQL 連接 MySQL DB 取資料時發現中文的部份
會出現亂碼, 經查證是 com.maclema.mysql.ResultSet 裡的Code有問題












internal function initialize(charSet:String):void {
        charSet = charSet;
        ....
}

以上是Source Code的部份, 這樣子是無法將外部定義的charSet傳入
需將 Code  修改為



internal function initialize(charSet:String):void {
        this.charSet = charSet;
        ....
}

然後在MXML中使用MysqlService時, 需定義charSet="utf8"


<assql:MySqlService id="service"
                hostname="localhost"
                username="root"
                password="smile69"
                database="smilelight"
                autoConnect="true"
                charSet="utf8"
                connect="handleConnected(event)"
                sqlError="handleError(event)" />


中文字才會顯示正常

沒有留言:

張貼留言