Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I develop a delphi7 webbroker multilanguage application for apache2,2. The application is using Oracle xe11 for data storage, and Devart's ODAC components to communicate with the Database. I set up the Orasession component as to use Unicode. The data inside the database was stored properly in Unicode capable data type columns. With another desktop application , also written in Delphi 7 we are able to store, retrieve and display correctly the same data of the database (I’m using Unicode capable components). My problem occurs when I want to display these data with the webbroker appl in html format. I’m using the default components provided by delphi 7 (TWebResponse). All text which are in Latin characters displaying correctly but all the others which are in different languages (not latin) not. Can you suggest me what have I do to solve the problem?

Are the non-latin characters mssing completely or is there displayed something different (e.g. ä instead of ä)? What is the charset specified in the generated html? How are the characters actually encoded? Chris Jan 16, 2015 at 13:24 Well the non-latin characters are displayed but but not correct, for example the character Ü (a Turtkish letter) as U. The character in the generated html is utf-8. Hb-IT Jan 16, 2015 at 13:30

(How) do you encode the unicode output of your components to the non-unicode capable (Ansi)String of TWebResponse.Content?

I guess the system codepage does not contain Ü (probably the same as the German Umlaut Ü -> U+00DC) and you are using an implicit conversion to (Ansi)String that takes the best mapping it can.

At least in Delphi 2006 you can / have to use

function Utf8Encode(const WS: WideString): UTF8String;

in system.pas (utf8string is a string - defined in same unit). As far as I know that function was there also in in Delphi 7.

Thank you for your answer, I do use Utf8Encode when I pass the content of the database to Twebresponse : Response.content := utf8Encode(ff) where ff is a widestring. – Hb-IT Jan 19, 2015 at 7:14 Sorry, then I don't have another idea at the moment. Have you checked (e.g. memory dump or mem view in debugger) whether the special char is there in the widestring you pass to utf8Encode? Maybe it has been "destroyed" before. – Chris Jan 19, 2015 at 8:40 Well I changed the compiler and turn into Delphi xe7, using the same code and the problem remains. No correct display of unicode characters. I made another desktop application using the same components to connect to oracle database and the result was fine. All the text in every languages stored in the databases displayed perfect. I thing that Delphi xe7 does support unicodes. I try now to find a solution – Hb-IT Jan 20, 2015 at 6:18 To test I wrote the follow simple action in the XE7 IDE: Response.ContentType := 'text/html; charset=utf8'; Response.Content := Turkish sign out :'+'-out-Bütün renk sistemleri-'; Response.SendResponse; handled:=true; The result in the browser is : Turkish sign out :-out-Butun renk sistemleri- You can see that the character "ü" was replaced by "u" – Hb-IT Jan 20, 2015 at 7:49 In Delphi XE7 (probably all >=2009) Content is (Unicode)String. I don't know whether / how it is encoded auttomatically. You could try TWebResponse.RawContent or TWebResponse.ContentStream. – Chris Jan 21, 2015 at 8:38

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.