广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 9451 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
笑笑 会员卡 葫芦墩家族
个人文章 个人相簿 个人日记 个人地图
发文大师奖
头衔:    
风云人物
级别: 风云人物 该用户目前不上站
推文 x137 鲜花 x523
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[Delphi][教学] Delphi + ZeosLib + MySQL + UTF8 HowTo
最近公司的资料库要升级为 UTF-8 所以遇到了蛮多的问题,公司的管理系统是用 Delphi 开发的,而资料库是 MySQL,这几天好不容易把资料库由 big5 转为 utf-8 ,不过读进来都是乱码,后来在网路上找到一篇不错的教学,有用到的可以参考看看

转贴自

After fiddling around with all these components I finally made a working database connection with my server. It appears to me, that all connections made to MySQL 4.1 default to the "latin1" encoding no matter what the database contains. To work with utf8 you have to tell Zeos to set up certain server variables. You can do this by executing the SQL command: "SET character_set_connection=utf8; SET character_set_results=utf8;" Starting that moment, MySQL expects to get ALL commands in utf8 and will also return all datasets in utf8! You can put these variables into your TZConnection.Properties String list:

character_set_connection=utf8
character_set_results=utf8
Hint: If you want Mysql to use 100% utf8 internally, just add the following to your TZConnection.Properties:

character_set_client=utf8
character_set_connection=utf8
character_set_database=utf8
character_set_results=utf8
character_set_server=utf8
character_set_system=utf8
collation_connection=utf8_general_ci
collation_database=utf8_general_ci
collation_server=utf8_general_ci
Codepage=utf8
Now that MySQL is returning everything in utf8 you have to make sure to use WideString variables ALWAYS.
For NON-BLOB fields you can use the following:

VAR MyString : WideString;
VAR DBString : UTF8String;
[...]
DBString := MyTable.FieldByName( ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容




每天大笑三声,可以让你更长寿哦...^^
献花 x0 回到顶端 [楼 主] From:台湾中华电信HINET | Posted:2008-06-13 09:02 |
highleekimo
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

有没有中文教学

英文看不太懂 表情


献花 x0 回到顶端 [1 楼] From:台湾中华HiNet | Posted:2009-06-24 11:17 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.018772 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言