bioman 1 Posted June 26, 2020 Hello Andrea Thank you for unveiling a great REST library, MARSI 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
Yaron 53 Posted June 26, 2020 You are not very clear, I believe mars translates everything to unicode, I have no issues with UTF8 encoded content. 1 Share this post Link to post
Andrea Magni 75 Posted June 27, 2020 @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
bioman 1 Posted June 27, 2020 (edited) 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 June 27, 2020 by bioman Share this post Link to post
bioman 1 Posted June 30, 2020 (edited) On 6/27/2020 at 11:58 PM, bioman said: Edited June 30, 2020 by bioman Share this post Link to post
Andrea Magni 75 Posted June 30, 2020 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 1 Share this post Link to post
bioman 1 Posted July 2, 2020 (edited) 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 July 2, 2020 by bioman 1 Share this post Link to post