Recent

Author Topic: Problem with format?  (Read 1187 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1289
Problem with format?
« on: August 04, 2021, 08:49:27 am »
Hope that you will read this.
Following is a script from web module, as you see that there are <h3>.  TCF is a TStringList.

Anyway ts1 reproduce correctly, while ts2 does not displayed correctly.

Code: Pascal  [Select][+][-]
  1.           ts := '이것이 한글 코드입니다';
  2.           ts1 := '<h3>[' + ts + '] ' + TCF.Values['title'] + '</h3>';
  3.           ts2 := Format('<h3>[%s] %s</h3>',[ts, TCF.Values['title']]);      

Actually this is not easy to reproduce --- but it happen repeatedly on my specific program.  System is Windows 10, Korean characters, Locale is Korean characters, but not set to use UTF-8 to display global languages.

Is it possible that something is done in format function?  I'm using format widely and not suffering any problem in most cases. I suspect that it caused some problems only in web module.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5473
  • Compiler Developer
Re: Problem with format?
« Reply #1 on: August 04, 2021, 08:59:03 am »
Would you please print the StringCodePage of all three strings? (and maybe also of the string returned by TCF.Values['title'])

egsuh

  • Hero Member
  • *****
  • Posts: 1289
Re: Problem with format?
« Reply #2 on: August 04, 2021, 09:20:45 am »
I have made a web page.

Please check at :

   http://alphaq.codns.com/aqtest/aq_svc_c/test

Source codes are:

Code: Pascal  [Select][+][-]
  1.    WebPage:= TStringList.Create;
  2.  
  3.    WebPage.Add('<!DOCTYPE html><html><head>');
  4.    WebPage.Add('<title>Alpha Q view progress</title>');
  5.    WebPage.Add('<meta charset="utf-8">');
  6.    WebPage.Add('<meta name="viewport" content="width=device-width">');
  7.    WebPage.Add('</head><body>');
  8.    WebPage.Add('<h1>Charset test</h1>');
  9.  
  10.    qr2.SQL.Text:= 'select project_desc from projects where project_id=:pid';
  11.    qr3.SQL.Text:= 'select Solicitor_desc from Solicitors where Solicitor_id=:sid' ;
  12.  
  13.    qr2.Prepare;
  14.    qr2.ParamByName('pid').AsString:= pid;
  15.    qr2.Open;
  16.  
  17.    qr3.Prepare;
  18.    qr3.ParamByName('sid').AsString:= sid;
  19.    qr3.Open;
  20.  
  21.    ts1:= qr2.Fields[0].AsString;
  22.    ts2:= qr3.Fields[0].AsString;
  23.  
  24.    WebPage.Add('<h2> Using Format --- </h2>');
  25.    WebPage.Add(Format('<h3>Project: %s</h3>', [ts1]));
  26.    WebPage.Add(Format('<h3>Solicitor: %s</h3>', [ts2]));
  27.  
  28.    WebPage.Add('<br>');
  29.  
  30.    WebPage.Add('<h2> Using string + string  </h2>');
  31.  
  32.    WebPage.Add('<h3>Project: ' + ts1 + '</h3>');
  33.    WebPage.Add('<h3>Solicitor: ' + ts2 + '</h3>');
  34.    WebPage.Add('<br>');
  35.  
  36.    WebPage.Add('StringCodePage of First string : %d<br>', [StringCodePage(ts1)]);
  37.    WebPage.Add('StringCodePage of second string : %d', [StringCodePage(ts2)]);
  38.  
  39.    WebPage.Add('</body></html>');
  40.  
  41.    AResponse.Content:= WebPage.Text;
  42.  
  43.    WebPage.Free;
  44.    Handled:= true;
  45.  

 

TinyPortal © 2005-2018