Jump to content
bioman

I don't think UTF-8 applies during the MARS project.

Recommended Posts

Hello Andrea
 

Thank you for unveiling a great REST library, MARS
I don't think UTF-8 applies during the MARS project.

Files created in UTF-8 format are also called 'Content-Type=text/html; charset=ISO-8859-1'

UTF-8 must be applied.

Can you help me?

Share this post


Link to post

You are not very clear, I believe mars translates everything to unicode, I have no issues with UTF8 encoded content.

  • Like 1

Share this post


Link to post

@bioman, hi, thanks for the kind words about MARS!

Would you please paste here the prototype of your method? What data type the result is?

 

Sincerely,

Andrea

Share this post


Link to post

Thank you for your response.

 

--

 

This is a simple page where you enter the address to view maps and GPS coordinates.

 

http://115.68.120.145:20020/rest/iot/maps/geocoding.html

 

The itot_geocoding.html file is encoded in UTF-8 format. But  it's on IOS-8859-1.

 

REST Debugger Request Header 

  Connection=close
  Date=Sat, 27 Jun 2020 14:46:16 GMT
  Content-Length=11953
  Content-Type=text/html; charset=ISO-8859-1

 

--

 

Compiling MARS.DCS.dproj results in the following error:

[dcc32 Error] MARS.http.Server.DCS.pas(22): E2291 Missing implementation of interface method IMARSRequest.GetQueryParamName
[dcc32 Error] MARS.http.Server.DCS.pas(22): E2291 Missing implementation of interface method IMARSRequest.GetDate
[dcc32 Error] MARS.http.Server.DCS.pas(181): E2250 There is no overloaded version of 'All' that can be called with these arguments
[dcc32 Fatal Error] MARS.DCS.dpk(39): F2063 Could not compile used unit 'MARS.http.Server.DCS.pas'

 

--

 

And the attached demo project also generates some compilation errors.

 

 


Thank you.

 

Edited by bioman

Share this post


Link to post
On 6/27/2020 at 11:58 PM, bioman said:

 

 

Edited by bioman

Share this post


Link to post

Hi @bioman,

thanks for pointing out compilation broke. I just fixed it: https://github.com/andrea-magni/MARS/issues/94

 

About the encoding, MARS is a layer of abstraction over the transport protocol (http). You implement your method (I guess) returning a Delphi string value.

MARS serializes (where needed) the values to a stream that will be used as the response of the request. Then, it's the underlying http library (MARS supports Indy, WebBroker over Apache module and IIS ISAPI and, more recently, Delphi Cross Socket framework) that sends the content to the client.

Indy has this trend of setting Content-Type=text/html; charset=ISO-8859-1 as default so sometimes you get it (when using Indy/WebBroker as http layer for MARS).

MARS (and Indy neither) can't easily say if your string is a UTF8 or MBCS or ANSI string, but you should know for sure.

So, if you are sending an UTF8 content in your string, mark your resource/method with an Encoding attribute stating so.

[GET, Path('geoconding.html'), Encoding('UTF-8')]
function MyContentGenerator: string;

 

Let me know if you solve this way!

Sincerely,

Andrea

  • Haha 1

Share this post


Link to post

Thank you for your kind reply.
We'll test it out the way you told us.
I'll let you know the result again.
Always be healthy and good luck to you.

Edited by bioman
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×