Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ActiveRecord can't store unicode data correctly #493

Closed
DelphiMan68 opened this issue Apr 4, 2021 · 3 comments
Closed

ActiveRecord can't store unicode data correctly #493

DelphiMan68 opened this issue Apr 4, 2021 · 3 comments
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone open Some team member is working on this

Comments

@DelphiMan68
Copy link

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
@danieleteti
Copy link
Owner

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

@danieleteti danieleteti added accepted Issue has been accepted and inserted in a future milestone open Some team member is working on this labels Apr 5, 2021
@danieleteti danieleteti added this to the 3.2.2-nitrogen milestone Apr 5, 2021
@danieleteti
Copy link
Owner

Any news?

@DelphiMan68
Copy link
Author

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
accepted Issue has been accepted and inserted in a future milestone open Some team member is working on this
Projects
None yet
Development

No branches or pull requests

2 participants