This issue does not occur with PostgreSQL, but it does with Firebird.
The default file format for Lazarus is UTF8, the CharSet for IBConnection is UTF8, and the file format for Firebird 4.0 is UTF8.
The params attribute of IBConnection is set to lc_ctype=UTF8
sc_dpb_utf8_filename=1.
After populating the DBGrid with the query results from SQLQuery, field status_display displays messy code.
select
CASE
WHEN status = TRUE THEN '启用'
WHEN status = FALSE THEN '禁用'
ELSE '未知'
END AS status_display,
name,
code
from sys_department
If using PostgreSQL and TPQConnection, the field status_display can be displayed normally.
It seems the setting of lc_ctype=UTF8 not work at all when using IBConnection。
I have to define a custom function to solve this problem for firebird.
CREATE OR ALTER FUNCTION TO_UTF8 (
SOMESTR VARCHAR(500)
)
RETURNS VARCHAR(500) CHARACTER SET UTF8
AS
BEGIN
RETURN CAST(SOMESTR AS VARCHAR(500) CHARACTER SET UTF8);
END;
thanks.