DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: liangjiping168
今日帖子: 15
在线用户: 19
导航: 论坛 -> 数据库专区 斑竹:liumazi,waterstone  
作者:
男 ww1000 (Delphis) ▲▲▲▲▲ -
普通会员
2023/1/13 21:34:51
标题:
utf8 字符集 的 SQLITE 数据库,如何解决写入 iso8859 字符新增ç”3报æ 乱码 浏览:820
加入我的收藏
楼主: 1个utf8 字符集 的 SQLITE 数据库,写入含 æ 的字符串会乱码,
查网后得知是 iso8859 字符集,

写入代码:
Sql:='insert into table(ABC) values '+Str;

请问如何转码?  iso8859 -> utf8      /utf16

谢谢.
----------------------------------------------
阳光总在
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/1/14 1:57:05
1楼: StackOverFlow post:

Using Dephi's built-in AnsiString charset support is best:

type
  // ISO-8859-1 and Windows-1252 are NOT the same, but
  // are commonly interchanged when they should not be!
  Latin1String = type AnsiString(28591);
  Windows1252String = type AnsiString(1252);
  GreekString = type AnsiString(1253);

procedure DoIt;
var
  S1: Latin1String;
  S2: Windows1252String;
  S3: GreekString;
begin
  S1 := '...'; // auto-converts to ISO-8859-1
  S2 := S1; // auto-converts from ISO-8859-1 to Unicode to Windows-1252
  S3 := S1; // auto-converts from ISO-8859-1 to Unicode to Greek
end; 

----------
see about usage of
MultiByteToWideChar(...) <=> WideCharToMultiByte(...)

https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar

https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/1/14 2:02:37
2楼: see  unit "IdCharsets.pas" with Charset names
GB2312 - 936 - chinese simplified
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2023/1/14 2:13:11
3楼: see here a sample about convert charsets using SQLite and Delphi

SQLite Character Encodings
Converting from ANSI to UTF8

https://1st.bitbumper.de/sqlite-ansi-utf8/
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 ww1000 (Delphis) ▲▲▲▲▲ -
普通会员
2023/1/15 13:29:38
4楼: Thx,guy
----------------------------------------------
阳光总在
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行78.125毫秒 RSS