Recent

Author Topic: [solved] how to print the 256 charracters of ISO8859 in lazarus?  (Read 13560 times)

dcelso

  • Full Member
  • ***
  • Posts: 158
[solved] how to print the 256 charracters of ISO8859 in lazarus?
« on: February 05, 2013, 06:51:42 pm »
hello, I have a loop for i = 0 to 255 and I would like print on a lavel.caption or memo.text the 256 character of represation of this number.
thanks
« Last Edit: February 08, 2013, 02:33:33 pm by dcelso »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: how to print the 256 charracters of ISO8859 in lazarus?
« Reply #1 on: February 06, 2013, 11:13:50 am »
Code: [Select]
Label.Caption := '';
for i := 0 to 255 do Label.Caption := Label.Caption + Chr(i);

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: how to print the 256 charracters of ISO8859 in lazarus?
« Reply #2 on: February 06, 2013, 11:40:02 am »
Code: [Select]
uses LConvEncoding, character;
...
procedure TForm1.Button1Click(Sender: TObject);   
var Uc:UnicodeChar;
  i:integer;
begin
  Memo1.Clear;
  for i:=0 to 255 do
    begin
     Uc:=UTF8Decode(ISO_8859_1ToUTF8(chr(i)))[1];
     if not TCharacter.IsControl(Uc) then
       Memo1.Lines.Add(UTF8Encode(Uc)) else
         Memo1.Lines.Add('Control Character '+inttostr(i));
    end;
end; 

dcelso

  • Full Member
  • ***
  • Posts: 158
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #3 on: February 07, 2013, 01:59:39 pm »
thank you a lot of, very simple example. I like it.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #4 on: February 07, 2013, 02:52:10 pm »
When I try this it fails to compile at the following line
Code: [Select]
    Memo1.Lines.Add(UTF8Encode(Uc)) else
with the error
unit1.pas(44,24) Error: Can't determine which overloaded function to call

Any ideas?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #5 on: February 07, 2013, 03:10:30 pm »
Any ideas?

It works here:
Free Pascal Compiler version 2.7.1 [2013/01/24] for x86_64
Lazarus 1.1 r40120M x86_64-linux-gtk 2

Does typecasting help?

Code: [Select]
Memo1.Lines.Add(UTF8Encode(UnicodeString(Uc))) else

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #6 on: February 07, 2013, 04:00:11 pm »
Theo, you forgot to mention that your example is dependent on your (a very well written and useful) utf8tools package. :)

However, not this line actually, but the one above it.  %)
« Last Edit: February 07, 2013, 04:02:41 pm by Zoran »
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #7 on: February 07, 2013, 04:03:17 pm »
Theo, you forgot to mention that your example is dependent on your (a very well written and useful) utf8tools package. :)

Thank you, but it's not. There is now a character.pas unit in the FPC RTL.
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/objpas/character.pas?view=log

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #8 on: February 07, 2013, 04:44:50 pm »
Then you forgot it's dependent on trunk :)

Never mind, thanks for the code & the example.... and hoping unicode support will finally take off...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #9 on: February 07, 2013, 05:11:55 pm »
Then you forgot it's dependent on trunk :)

You are right. It's about time for FPC 2.8. ;-)
There are other important things missing in 2.6 like MySQL 5.5 support etc.

dcelso

  • Full Member
  • ***
  • Posts: 158
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #10 on: February 07, 2013, 05:24:59 pm »
 :o, € symbol is not in ISO8850_1, I need lastest modification ISO8859_15

http://en.wikipedia.org/wiki/ISO/IEC_8859-15

¿It is possible to implement in lazarus?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: [solved] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #11 on: February 07, 2013, 05:28:27 pm »
:o, € symbol is not in ISO8850_1, I need lastest modification ISO8859_15

http://en.wikipedia.org/wiki/ISO/IEC_8859-15

¿It is possible to implement in lazarus?

Why do you want that? You have Unicode (UTF-8) in Lazarus, all symbols and characters are there.

dcelso

  • Full Member
  • ***
  • Posts: 158
Re: [reopened] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #12 on: February 07, 2013, 06:15:13 pm »
Because im making a tool helper for anothe program that only uses iso8859 to write text. So it is my unique requirement,

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1934
Re: [reopened] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #13 on: February 07, 2013, 06:27:12 pm »
Not sure if I understand. But you can see in your http://en.wikipedia.org/wiki/ISO/IEC_8859-15, that
€ is at $A4, so you can simply replace the symbol representing this number with UTF-8 €.

 

dcelso

  • Full Member
  • ***
  • Posts: 158
Re: [reopened] how to print the 256 charracters of ISO8859 in lazarus?
« Reply #14 on: February 07, 2013, 06:48:02 pm »
 :o, good trick. I coud do it, because the posibility that an ISO_8859_15ToUTF8 wiould exists is not possible for now. ¿dont?

 

TinyPortal © 2005-2018