Recent

Author Topic: Displaying Arabic on Console  (Read 5807 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Displaying Arabic on Console
« Reply #30 on: May 12, 2021, 11:15:59 pm »
Easiest to debug a particular setup is to see what bytes are sent to the console using strace.

tetrastes

  • Sr. Member
  • ****
  • Posts: 473
Re: Displaying Arabic on Console
« Reply #31 on: May 13, 2021, 12:13:37 am »
Very strange. I added
Code: Pascal  [Select][+][-]
  1. {$codepage utf8}
to your first code, and the output was question marks instead of arabic letters.
Is this bug in fpc? (I have 3.2.0 linux x86_64)
After searching documentation https://wiki.lazarus.freepascal.org/Unicode_Support_in_Lazarus I found that it is not a bug  :) :
Quote
What happens when I use $codepage utf8?
FPC has very limited UTF-8 support. In fact, FPC only supports storing literals as either "default" encoded 8-bit strings or widestrings. So any non default codepage is converted to widestring, even if it is the system codepage. For example most Linux/Mac/BSD use UTF-8 as system codepage. Passing -Fcutf8 to the compiler will store the string literal as widestring.

At run time the widestring literal is converted. When you assign the literal to an AnsiString the widestring literal is converted using the widestringmanager to the system encoding. The default widestringmanager under Unix simply converts the widechars to chars, destroying any non ASCII character. You must use a widestringmanager like the unit cwstring to get correct conversion. Unit LazUTF8 does that.


So it is better not to use $codepage directive at all.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: Displaying Arabic on Console
« Reply #32 on: May 13, 2021, 07:44:35 am »
Hey Pascal111,

First of all I'm sorry that I used Google Translate to murder Arabic :) I'll never do it again, promise  :-[
Second of all I want to apologise because I'm not gonna quote reply to your post. I got a bit lost.

Ok, so after reading that Pascal111 doesn't know where is the Lazarus font for the Editor, and my need to know what font I'm using on MY gnome-terminal I screenshotted the included images.

The first image is the Default Profile of gnome-terminal where you can find(to my utter surprise) that the font is NOT, I repeat NOT Monospace Regular 12. It only BECOMES that if you tick the Custom Font check box close to it.

This means that you'll have to find out what is the default Ubuntu system font for the gnome-terminal another way. One I haven't found yet.

The second image is where you, Pascal111, can find the font that Lazarus uses in it's TSynEdit component.
You go to Tools->Options and then click on (1)Display and on (2)Default editor font you can see that I've changed mine to Fira Code.

And BTW, Pascall111, when I mentioned TSynEdit it was in the context of that component being the one that Lazarus depends for it's editor.

All this to go nowhere I suppose since I can't help any further without finding what is the system font that gnome-terminal uses and then compare it with the one that TSynEdit is using on Lazarus.

I'll probably report back once I find out where to assess what the default Monospace font is for gnome-terminal.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #33 on: May 13, 2021, 12:40:45 pm »
Hey Pascal111,

First of all I'm sorry that I used Google Translate to murder Arabic :) I'll never do it again, promise  :-[
Second of all I want to apologise because I'm not gonna quote reply to your post. I got a bit lost.

أنت رجل حُر ،كُنتُ أعني أن تكون الترجمة مفهومة ولذا أظنّ أن الترجمة الأنسب هي بترجمة عبارة عبارة.

google translate:

"You are a free man, I meant that the translation was "to be" understandable and so I think the most appropriate translation is to translate the phrase "by" phrase."

Ok, so after reading that Pascal111 doesn't know where is the Lazarus font for the Editor, and my need to know what font I'm using on MY gnome-terminal I screenshotted the included images.

The first image is the Default Profile of gnome-terminal where you can find(to my utter surprise) that the font is NOT, I repeat NOT Monospace Regular 12. It only BECOMES that if you tick the Custom Font check box close to it.

This means that you'll have to find out what is the default Ubuntu system font for the gnome-terminal another way. One I haven't found yet.

The second image is where you, Pascal111, can find the font that Lazarus uses in it's TSynEdit component.
You go to Tools->Options and then click on (1)Display and on (2)Default editor font you can see that I've changed mine to Fira Code.

And BTW, Pascall111, when I mentioned TSynEdit it was in the context of that component being the one that Lazarus depends for it's editor.

All this to go nowhere I suppose since I can't help any further without finding what is the system font that gnome-terminal uses and then compare it with the one that TSynEdit is using on Lazarus.

I'll probably report back once I find out where to assess what the default Monospace font is for gnome-terminal.

Cheers,
Gus

لقد حللتُ مُشكلة الـ Terminal حيث أزلتُ مُوجّه {$codepage utf8}  فظهرت الحروف العربيّة على الـ Terminal إلّا أنّها مُفكّكة وتحتاج إلى ميزة RTL فنفّذت نفس البرنامج على Terminal آخر يُدعّم العربيّة بميزة الـ RTL فظهرت الكلمة مُنسّقة وكذلكـ تتبعتُ الخطوات التي أشرتَ إليها لمعرفة نوع الخط في بيئة Lazarus وأحضرت الخط وهو Courier New ومع هذه المشاركة صور توضيحيّة لما حدث.

google translate:

"I solved the Terminal problem where I removed the {$ codepage utf8} directive, so the Arabic letters appeared on the Terminal, but they are disjointed and need the RTL feature "So I used another terminal with RTL feature". "I followed your steps to know font of" Lazarus environment and brought in the font which is Courier New and with this post illustrations "images" of what happened."

(https://i.postimg.cc/Z92z0K1q/Screenshot-at-2021-05-13-12-19-27.png)

(https://i.postimg.cc/jwhVcQDD/Screenshot-at-2021-05-13-12-28-02.png)
La chose par la chose est rappelé.

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #34 on: May 13, 2021, 12:47:57 pm »
Very strange. I added
Code: Pascal  [Select][+][-]
  1. {$codepage utf8}
to your first code, and the output was question marks instead of arabic letters.
Is this bug in fpc? (I have 3.2.0 linux x86_64)
After searching documentation https://wiki.lazarus.freepascal.org/Unicode_Support_in_Lazarus I found that it is not a bug  :) :
Quote
What happens when I use $codepage utf8?
FPC has very limited UTF-8 support. In fact, FPC only supports storing literals as either "default" encoded 8-bit strings or widestrings. So any non default codepage is converted to widestring, even if it is the system codepage. For example most Linux/Mac/BSD use UTF-8 as system codepage. Passing -Fcutf8 to the compiler will store the string literal as widestring.

At run time the widestring literal is converted. When you assign the literal to an AnsiString the widestring literal is converted using the widestringmanager to the system encoding. The default widestringmanager under Unix simply converts the widechars to chars, destroying any non ASCII character. You must use a widestringmanager like the unit cwstring to get correct conversion. Unit LazUTF8 does that.


So it is better not to use $codepage directive at all.

كلامكـ صحيح ،لقد فعلتها وظهرت الحروف العربيّة على الـ Terminal ولكن ليس على الـ console الخاص بالـ debug في بيئة Lazarus.

google translate:

"You're right, I did it and the Arabic letters appeared on the terminal but not on the debug console in Lazarus environment."

(https://i.postimg.cc/jwhVcQDD/Screenshot-at-2021-05-13-12-28-02.png)
La chose par la chose est rappelé.

pascal111

  • Sr. Member
  • ****
  • Posts: 423
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #35 on: May 13, 2021, 12:52:55 pm »
Easiest to debug a particular setup is to see what bytes are sent to the console using strace.

أظنّ أنّ هذا أبعد من معرفتي.

google translate:

"I think this is beyond my knowledge."
La chose par la chose est rappelé.

 

TinyPortal © 2005-2018