Recent

Author Topic: FP in Linux Mint Terminal crazy characterset  (Read 4241 times)

alfware17

  • New Member
  • *
  • Posts: 40
FP in Linux Mint Terminal crazy characterset
« on: March 09, 2019, 04:58:04 pm »
Hi,
I normally program in Windows 7 using the Free Pascal IDE less or more or the comand line compiler.
Now I tried to port a batch program to run in Linux Mint 17. So far it works all BUT: my writeln - outputs
dont show german special characters Ä Ö Ü or ß and so on. Simply on desktop - I didnt gone into detail
yet to study if the files are correct, any logic and so on.

I tried both. in the IDE (lol the characters can be seen there but not then in the running program) and
in Terminal using comand line compiler,  I can type ä ö ü in the terminal all fine. Showing me the source
.pas in Krusader using F3 or F4 shows problems (sorry I am Linux beginner).

I just thought about transforming my source into UTF8 by tool as I did for one Java/Eclipse project before.
But I remember another project in LAZARUS (now no batch but OO) where I could use the sources as
well in both Windows and Linux Mint.

And now the special effect. I created "hello world" program in the FP IDE (started by simply FP in the terminal)
and wanted to writeln('ÄÖÜß') direct from keyboard. My typed letters where translated  into some cryptic. 8-)
Run the program - ok Ä Ö Ü ß on the screen.
But: creating a string constant with that content, writeln it - problem again.
Counting any single char of the string, writeln the char and the ORD code - problem.
For i:=1 to 255 do write(CHR(i)) - you may imagine, after 128 problem,

What do I make wrong? Anybody can tell me, whos ghosting me? Linux? The terminal?
Free Pascal?
If it helps, I have one more indiz: The only one line of code I disabled in my origin source
code when porting from Windows to Linux, was
DefaultSystemCodePage:=TextRec(Output).CodePage;   :-*
I got compiler error - dont know why by now. But I thought first solve the crazy
"hello world" behaviour then look, if my Windows Codepage problem with the
data is still needed in Linux.

Thank you for any help
Bernd

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: FP in Linux Mint Terminal crazy characterset
« Reply #1 on: March 09, 2019, 05:10:07 pm »
If you are using the Mint default Terminal app it has a six-item main menu: File Edit View Search Terminal Help.
The first item in the "Terminal" menu is "Set character encoding ->" which gives you a massive drop-down of possible choices, and you need to ensure that you encode the characters your app sends to the Terminal in the way it expects to interpret them.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: FP in Linux Mint Terminal crazy characterset
« Reply #2 on: March 09, 2019, 05:16:43 pm »
Using DefaultSystemCodePage:=TextRec(Output).CodePage; in Windows, implies that you are using ANSI, intentionally, instead of UTF8. You are supposed to do the opposite, unless you have a very good reason.

Edit:
I found your previous thread.
« Last Edit: March 09, 2019, 09:25:23 pm by engkin »

alfware17

  • New Member
  • *
  • Posts: 40
Re: FP in Linux Mint Terminal crazy characterset
« Reply #3 on: March 10, 2019, 06:37:25 pm »
@ engkin. Yes I solved that in Windows. The problem is, most of my data is Ansi (old stuff from Turbo pascal and so on).
For new data I dont need and probably not in Linux but for Win 7 its tested/needed and runs. I deleted for Linux.

@howardpc:
I have the "default" Linux Mint from Live DVD installed and some new packages but I guess I never changed the terminal.
Showing me properties called "gnome-terminal". There is NO menue.
Do you advise any other? I havent any chance to try another Linux by now, maybe in a virtual box.
What make me really curios: when I type in the IDE and press say Ä key, it translates and includes some cryptic into
the source code? And then RUN - shows the described funny things, somes like that, somes other?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: FP in Linux Mint Terminal crazy characterset
« Reply #4 on: March 10, 2019, 07:55:38 pm »
Right-click on the terminal.
Gnome Terminal has a menu option "Show Menubar".
Or choose the Preferences option to open a dialog where under General you can check the option "Show menubar by default in new terminals".

alfware17

  • New Member
  • *
  • Posts: 40
Re: FP in Linux Mint Terminal crazy characterset
« Reply #5 on: March 11, 2019, 07:01:47 pm »
Hi howardpc,

my terminal has preferences but no menue  :o what general preferences do you mean?
Sorry, my Linux Mint is in German and I am not sure where to find. But I searched for...
I thought by myself - a picture says more than 1000 newbie words and made some screenshots.
Is the link allowed here? Sorry I hate that screenshot function in Linux, it makes me big megabytes.
And I tried to a) cut b) compress - its still big but no letter to be seen. So look for my dropbox link
please and admin dont kill me (nothing found against in the FAQ)

https://www.dropbox.com/sh/0u2wm9ji0drzt2q/AACHE9-DFlInJhb15LkhN1k6a?dl=0

The Shot5 is my terminal.

Shot 1 until 4 shows my problem.

Probably one way could be to take the source into IDE and change manually all comments
in the writeln I can find to be wrong??? But I didnt need to do with the Lazarus IDE?

Or second solution, convert the whole source to UTF8 before using it in Linux-

I know, its only the comments I can see as output of the program in the terminal.
I didnt spent any thought or idea what happens if the data/files could not be longer
processed because of the 1 or 2 bytes per character problem. I dont want to know about
that - first the outputs ::)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: FP in Linux Mint Terminal crazy characterset
« Reply #6 on: March 11, 2019, 08:39:40 pm »
<Not a solution>

shot1 shows that:
The terminal is expecting UTF8.
Krusader is not using UTF8, and most likely some ANSI.
See if you can make Krusader use UTF8.

shot2 shows that:
The IDE is not using UTF8 either.
The IDE is using ANSI, but not the same codepage as Krusader
I don't think the IDE is able to use UTF8.

shot3 and shot4 confirm that terminal is using UTF8.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: FP in Linux Mint Terminal crazy characterset
« Reply #7 on: March 11, 2019, 09:43:52 pm »
alfware17 - Sorry, we may be referring to different set-ups.
I was referring to the Mint 19 Cinnamon desktop which has the Gnome Terminal as shown below.

alfware17

  • New Member
  • *
  • Posts: 40
Re: FP in Linux Mint Terminal crazy characterset
« Reply #8 on: March 12, 2019, 02:00:46 pm »
@ engkin: hm, by now the only way to satisfy the Terminal seems to be
- load the source into IDE and then repair manually. Not 21st century like but ok. But then I have 2 sources - Linux and Windows - and must synchronize.
  Do you know any other extern Editor working fine with FPC and producing german signs? %)

  FPC version is 2.6.2 come with the Lazarus. Dont know if update would help, but Linux Mint is rather not updating

  The other question would be, if somebody else uses my binary in another Terminal, what happens?

- another solution I could try is to use my UTF8-Unit I build for another Lazarus project I had problems with but now working fine.
  have there a "writeutf8ln" and it does for me.

  The problem is, I used a unit LConvEncoding comes with Lazarus seems FPC doesnt include it.
  Is there any comparable in FPC?
 

Thaddy

  • Hero Member
  • *****
  • Posts: 14214
  • Probably until I exterminate Putin.
Re: FP in Linux Mint Terminal crazy characterset
« Reply #9 on: March 12, 2019, 02:16:10 pm »
  FPC version is 2.6.2 come with the Lazarus. Dont know if update would help, but Linux Mint is rather not updating

FPC 2.6.2. is more than five years old...... And unmaintained for three.
We simply can't test those things....
Specialize a type, not a var.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: FP in Linux Mint Terminal crazy characterset
« Reply #10 on: March 12, 2019, 06:50:10 pm »
  Do you know any other extern Editor working fine with FPC and producing german signs? %)
Lazarus.  :D
You can even choose/change the encoding of the file:
Right Click >> File Settings >> Encoder

  FPC version is 2.6.2 come with the Lazarus. Dont know if update would help, but Linux Mint is rather not updating
FPC 2.6.2 does not know about code pages. If you update, Thaddy would help you as well.

  The other question would be, if somebody else uses my binary in another Terminal, what happens?
As long your code does not have anything specific to your system, probably it will show the same results.

  The problem is, I used a unit LConvEncoding comes with Lazarus seems FPC doesnt include it.
  Is there any comparable in FPC? 
Newer versions do. Your WriteUTF8Ln, assuming zeile has the correct code page, become:
Code: Pascal  [Select][+][-]
  1. procedure WriteUTF8Ln(zeile: string);
  2. begin
  3.    //WriteLn(CP1252toUTF8(zeile));
  4.    SetCodePage(RawByteString(zeile), 65001{UTF8}, True{Convert});
  5.    WriteLn(zeile);
  6. end;

If zeile does not hold the correct code page:
Code: Pascal  [Select][+][-]
  1. procedure WriteUTF8Ln(zeile: string);
  2. begin
  3.    //WriteLn(CP1252toUTF8(zeile));
  4.    SetCodePage(RawByteString(zeile), 1252{cp1252}, False{Do not Convert});
  5.    SetCodePage(RawByteString(zeile), 65001{UTF8}, True{Convert});
  6.    WriteLn(zeile);
  7. end;

alfware17

  • New Member
  • *
  • Posts: 40
Re: FP in Linux Mint Terminal crazy characterset
« Reply #11 on: March 13, 2019, 02:19:27 pm »
Ok thanks so far. I guess I must look for newer FPC in Linux.
Another problem I faced this morning - other people/other terminal cannt even run my binary.
because my Lazarus/FPC produces 64bit binaries (but she has 32bit OS).
I didnt even known or care until now. Or say until last year, I used 32bit exclusively,
was the "small".
OK, the live DVD was 64bit, so thats clear without me knowing that I am the incompatible "big" :P

Seeing that I think I would need a newer Lazarus/FPC but 32bit to solve both UTF-8 and other people terminal problems.
I did that already in Windows, have 2 different directories, 2 installations, 2 icons and it works fine I can choose.

But in Linux I am a newbie. Simply getting the .deb packages and install them parallel to the existing one (I dont want to lose some working)?
Keeps my sqlite alive and reachable for both installations?

The older Lazarus (1.4 may be I remember and FPC 2.6.2) came from pre-installed package.
 I am not sure about what happens, even if I can choose different directories for installing?

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: FP in Linux Mint Terminal crazy characterset
« Reply #12 on: March 13, 2019, 05:04:43 pm »
Ok thanks so far. I guess I must look for newer FPC in Linux.
Another problem I faced this morning - other people/other terminal cannt even run my binary.
because my Lazarus/FPC produces 64bit binaries (but she has 32bit OS).
I didnt even known or care until now. Or say until last year, I used 32bit exclusively,
was the "small".
OK, the live DVD was 64bit, so thats clear without me knowing that I am the incompatible "big" :P

Seeing that I think I would need a newer Lazarus/FPC but 32bit to solve both UTF-8 and other people terminal problems.
I did that already in Windows, have 2 different directories, 2 installations, 2 icons and it works fine I can choose.

But in Linux I am a newbie. Simply getting the .deb packages and install them parallel to the existing one (I dont want to lose some working)?
Keeps my sqlite alive and reachable for both installations?

The older Lazarus (1.4 may be I remember and FPC 2.6.2) came from pre-installed package.
 I am not sure about what happens, even if I can choose different directories for installing?

You should do some research on LXC containers and create a i386 container for Debian distribution.

 

TinyPortal © 2005-2018