#1 2019-12-18 17:38:10

halted
Member
Registered: 2019-12-18
Posts: 4

Character encoding

Hi,
I'm trying Mormot in a rest service context. The entry sends the result as stream.

I'm using

<Code>
...
Props := TSQLDBFireDACConnectionProperties.Create('MSSQL?Server=' + lsServerName ,lsDatabaseName,lsUserName,lsPassword);
...
  try

    Conn := Props.NewConnection;

    try
      Conn.Connect;
      Query := Conn.NewStatement;
      try
        lpoS := TMemoryStream.Create;

        Query.Execute(lsSql,true,[]);

        Query.FetchAllToJSON(lpoS,true);

        Result := lpoS;

      finally
        Query.Free;
      end;
    finally
      Conn.Free;
    end;
  finally
    Props.Free;
  end;

</Code>


The result is fine except for french accents :

{"RefValueId":8000000000050100062,"Label":"Négociateur GIE AC"},{"RefValueId":8000000000050100063,"Label":"Négociateur GIE AEC"}

Is there something to do to force character encoding ?

Database server is SQL Server 2012
Columns in database table are NVARCHAR(xx)
IDE is Delphi 10.3.3

Regards,

JM

Last edited by halted (2019-12-18 17:39:49)

Offline

#2 2019-12-18 20:54:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Character encoding

The resulting JSON is expected to be UTF-8 encoded in the stream.
So I guess é is é in UTF-8.

Offline

#3 2019-12-18 22:17:45

halted
Member
Registered: 2019-12-18
Posts: 4

Re: Character encoding

Yes the Content-Encoding header was missing in the respose build by the server.

Many thanks for this awesome work !

Offline

Board footer

Powered by FluxBB