Recent

Author Topic: How To Display Greek Numerals in 'Application' TEdit object?  (Read 2851 times)

-Caiman-

  • New Member
  • *
  • Posts: 10
How To Display Greek Numerals in 'Application' TEdit object?
« on: January 07, 2019, 08:04:40 pm »
Hello guys, I already asked you how to display Greek numerals in the console (thx for help btw.) : http://forum.lazarus-ide.org/index.php/topic,43739.0.html
But now I cannot find the way to display UNICODEstring in TEdit object because it supports only String to display. Is there any convert function like IntToStr or library to add to make it work? Thx for answers!

CCRDude

  • Hero Member
  • *****
  • Posts: 597
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #1 on: January 07, 2019, 08:15:10 pm »
Are you looking for the UTF8Encode() function maybe?

-Caiman-

  • New Member
  • *
  • Posts: 10
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #2 on: January 07, 2019, 08:23:31 pm »
I tried it now, no warning messege now but still not worked. Am I using it right?

balazsszekely

  • Guest
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #3 on: January 07, 2019, 08:34:11 pm »
With fpc3.0.0 + a simple assignment should be enough:
Code: Pascal  [Select][+][-]
  1. var
  2.   UStr: UnicodeString;
  3. begin
  4.    Edit1.Text := UStr;
  5. end;
Are you sure that SYM is an unicodestring? Can you post a small demo application?

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #4 on: January 07, 2019, 08:39:11 pm »
It should be converted automatically, when you assign a UnicodeString to a String; i.e. this should work without more ado:

Code: Pascal  [Select][+][-]
  1. procedure SetTextForEdit(AnEdit: TEdit; const AText: UnicodeString);
  2. begin
  3.   AnEdit.Text := AText;
  4. end.

I have just tested something similar (only using an Spanish test string) and it does work.

ETA: Ahh ... yeah, what GetMem said.
« Last Edit: January 07, 2019, 08:41:17 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

-Caiman-

  • New Member
  • *
  • Posts: 10
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #5 on: January 08, 2019, 01:51:13 pm »
With fpc3.0.0 + a simple assignment should be enough:
Code: Pascal  [Select][+][-]
  1. var
  2.   UStr: UnicodeString;
  3. begin
  4.    Edit1.Text := UStr;
  5. end;
Are you sure that SYM is an unicodestring? Can you post a small demo application?
Potential data loss. Still not working. Yes, my SYM is UNICODEstring but its not const

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #6 on: January 08, 2019, 02:08:15 pm »
Your font needs to be able to display the characters in question (not all fonts support that).

If you are sure that UStr is a WideString (you're on Windows I see) / UnicodeString then Utf16ToUTf8(Ustr) should work.

Do you have DisableUTF8RTL defined in your project options?
If so, then assigning a UnicodeString to a String may indeed cause data loss: your current Windows codepage MUST support the character in it's ANSI codepage.

Bart

-Caiman-

  • New Member
  • *
  • Posts: 10
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #7 on: January 08, 2019, 02:41:57 pm »
WORKS!
Only added {$codepage utf8}  in the begining. Thx guys for replies!

balazsszekely

  • Guest
Re: How To Display Greek Numerals in 'Application' TEdit object?
« Reply #8 on: January 08, 2019, 03:01:38 pm »
Quote
Only added {$codepage utf8}  in the begining. Thx guys for replies!
It means you tried to assing a string literal to an unicodestring. That's not needed, you can use a regular string for that. UnicodeString/WideString is useful for api calls.

 

TinyPortal © 2005-2018