Skip to content

ActiveRecord can't store unicode data correctly #493

@DelphiMan68

Description

@DelphiMan68

161974345_3272038199564487_2838604728982442175_n
162132871_3272084629559844_131425475513518547_n

Hello everyone, 😍
ActiveRecord can't store unicode data correctly. I am using activerecord_showcase sample and trying to store some unicode text in database but data will be appear like ????? in database table! also 'CharacterSet=UTF8' parameter added into connection but wrong result appears again. I am using firebird3 and DMVC carbon edition.
✳️For reproduce problem you can try to store this string:
'این یک تست است!'
1️⃣ Update 1: this problem appears when English(United States) selected in this path in windows 10:
Control Panel>Region>Administrative>Change system locale...
2️⃣ Update 2: When Persian(Iran) selected from previous path then It works correctly. Is It possible to configure DMVC's ActiveRecord to working in any situations without changing Windows settings?
3️⃣ Update 3: bug solved 🙂
For solving this problem follow below steps:

  1. In MVCFramework.ActiveRecord.pas unit.
    ❌change below section:
    ftUnknown, ftString, ftWideString:
    begin
    aParam.AsString := aValue.AsString;
    end;
    ✅ To this:
    case aParam.DataType of
    ftUnknown, ftString, ftWideString:
    begin
    aParam.AsWideString := aValue.AsString;
    end;
  2. And in MVCFramework.ActiveRecord.pas unit.
    ❌change below section:
    {$IF Defined(SeattleOrBetter)}
    tkWideString:
    begin
    aParam.AsString := aValue.AsString;
    end;
    {$ENDIF}
    ✅ To this:
    {$IF Defined(SeattleOrBetter)}
    tkWideString:
    begin
    aParam.AsWideString := aValue.AsString;
    end;
    {$ENDIF}
    Special thanks for DMVC Framework team and specialy for Daniele Teti

Metadata

Metadata

Labels

acceptedIssue has been accepted and inserted in a future milestoneopenSome team member is working on this

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions