danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActiveRecord can't store unicode data correctly

DelphiMan68 opened this issue · comments

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

The fix is in the repo. Please, test it and let me know.

Any news?

Hello. Now It works fine :)
thank you for fixing this bug