Recent

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

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Displaying Arabic on Console
« on: May 11, 2021, 06:11:36 pm »
حاولتُ طباعة عدة عبارات عن طريق writeln على الـ console ولكن لم تظهر إلا علامات إستفهام مكان النّص حيث كانت العبارات المطلوب طباعتها عربيّة فهل الـ console لا يعرض إلى الـ Ascii code فقط؟

google translate:

"I tried to print several expressions using writeln on the console, but only question marks appeared in the place of the text, as the expressions to be typed were in Arabic, so is the console not only displayed in "except" the Ascii code?"

Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes
  10.   { you can add units after this };
  11.  
  12. begin
  13.  
  14.   writeln('هل تقرأ السطر الحالي؟');
  15.   writeln('ماذا تجد؟ كلمات ،وهل تراها جيّداً؟');
  16.   writeln('ماذا تقولُ هذه الكلمات؟ ليس أكثر من الإستفسار عن إذا كنت تقرؤها أم لا ،إنّها الشيء من اللاشيء!');
  17.  
  18.   writeln;
  19.  
  20.   writeln('Do you read the current line?');
  21.   writeln('What do you find? Words, and do you see them well?');
  22.   writeln('What do these words say? It is nothing more than asking if you are reading it or not, it is something out of nothing!');
  23. end.
  24.  
  25.  


(https://i.postimg.cc/N2jwYccg/Screenshot-at-2021-05-11-18-05-50.png)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9344
  • FPC developer.
Re: Displaying Arabic on Console
« Reply #1 on: May 11, 2021, 06:23:17 pm »
Try putting {$codepage utf8} after the {$mode line.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #2 on: May 11, 2021, 06:34:13 pm »
Try putting {$codepage utf8} after the {$mode line.

للأسف لم يعمل هذا الموجّه ،نتيجة التنفيذ كما هي.

google translate:

"Unfortunately this router "directive" did not work, as a result of implementation "running" as is."

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7177
  • Debugger - SynEdit - and more
    • wiki
Re: Displaying Arabic on Console
« Reply #3 on: May 11, 2021, 06:45:15 pm »
(if you are (still) on Linux, then) Try it from a terminal outside the IDE.

Just in case the build in IDE console window has a problem.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #4 on: May 11, 2021, 07:16:39 pm »
(if you are (still) on Linux, then) Try it from a terminal outside the IDE.

Just in case the build in IDE console window has a problem.

مازلتُ على الـ Linux فليس لديّ نسخة Windows مُرخّصة للإستخدام الشخصي.

قُمتُ بعمل compile للبرنامج فحاولتُ تشغيل ملفه التنفيذي مُتوقّعاً أن يعمل على الـ Terminal ولكنّني لم أرى أيّ أثرٍ ﻷيّ تنفيذ ولم تُفتح نافذة الـ Terminal أصلاً ،ثمّ ظننتُ أنّكـ تقصد مُحاولة تنفيذ ذلكـ عن طريق مُترجم fpc على الـ Terminal فنفّذت الأوامر التالية ولكن النتيجة كما هو موضّح أدناه:

google translate:

"I'm still on Linux as I do not have a licensed copy of Windows for personal use.

I "made a" compile the program and tried to run its executable file expecting it to work on the terminal, but I did not see any trace "effect" of any execution and the terminal window did not open at all, then I thought that you intended to try to implement run it via the fpc compiler on the terminal, so I executed the following commands, but the result is as shown Below:"

Code: Bash  [Select][+][-]
  1. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common$ fpc ./project1.lpr
  2. Free Pascal Compiler version 3.2.0 [2020/07/07] for x86_64
  3. Copyright (c) 1993-2020 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling ./project1.lpr
  6. Fatal: Cannot open file "project1.lpr"
  7. Fatal: Compilation aborted
  8. Error: /usr/bin/ppcx64 returned an error exitcode
  9. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common$
  10.  
  11.  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7177
  • Debugger - SynEdit - and more
    • wiki
Re: Displaying Arabic on Console
« Reply #5 on: May 11, 2021, 07:54:47 pm »
You can compile in the IDE.

After compile (if there was no error) you open a Terminal, and change into the project folder.

The exe may either be
./project
or
./lib/x86-64/project
or similar

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #6 on: May 11, 2021, 08:31:51 pm »
You can compile in the IDE.

After compile (if there was no error) you open a Terminal, and change into the project folder.

The exe may either be
./project
or
./lib/x86-64/project
or similar

فهمتُ ما تعنيه ،إنّكـ تعني أن يتم تنفيذ البرنامج على الـ Terminal بعد فتح الـ  Terminal أي أن يكون التنفيذ من خلاله وليس كما كُنتُ أظنّ أنّ الـ Terminal سينفتح تلقائيّاً عند النقر على أيقونة البرنامج المُترجم أو التنفيذي.

أودّ التنبيه كذلكـ أنّني في محاولتي التي ذكرتها في الـ post السّابق قد أحدثتُ خطأً إذ لمّا حاولت ترجمة البرنامج بـ fpc لم أكن وصلت بعد إلى مُجلّد البرنامج الصحيح بل كنتُ خارجاً في المُجلّد الذي قبله. عُموماً صححتُ تجربتي وقُمتُ بتنفيذ تعليماتكـ والبرنامج قد عمل بالفعل على الـ Terminal ولكن مازالت مُشكلة عرض النّص العربي قائمة فلم تظهر بعد الحروف العربيّة ومازالت علامات الإستفهام تظهر بالنيابة عنها.

google translate:

"I understood what you mean, you mean that the program is executed on the terminal after opening the terminal, meaning that the execution is through it and not as I had thought that the terminal would open automatically when clicking on the compiler "compiled" or executable program icon.

I would also like to warn "mention" that in my attempt that I mentioned in the previous post, I made an error as when I tried to compile the program with fpc, I did not yet reach the correct program directory, but I was out in the previous folder. In general, I corrected my experience "try" and implemented "ran" your instructions, and the program has already worked on the terminal, but the problem of displaying the Arabic text is still present, and it did not appear after "yet" the Arabic letters, but the question marks still appear on its behalf "instead of it"."

Code: Bash  [Select][+][-]
  1. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 8$ fpc ./project1.lpr
  2. Free Pascal Compiler version 3.2.0 [2020/07/07] for x86_64
  3. Copyright (c) 1993-2020 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling ./project1.lpr
  6. project1.lpr(9,3) Fatal: Can't find unit Interfaces used by project1
  7. Fatal: Compilation aborted
  8. Error: /usr/bin/ppcx64 returned an error exitcode
  9. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 8$ dir
  10. backup  project1      project1.lpi  project1.lps  unit1.lfm
  11. lib     project1.ico  project1.lpr  project1.res  unit1.pas
  12. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 8$ ./project1
  13.  
  14. (project1:11015): GLib-GIO-CRITICAL **: 20:18:30.475: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
  15. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 8$ cd..
  16. cd..: command not found
  17. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 8$ cd ../
  18. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common$ dir
  19. Project\ 1  Project\ 3  Project\ 5  Project\ 7  Project\ 9
  20. Project\ 2  Project\ 4  Project\ 6  Project\ 8  Projects\ description
  21. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common$ cd Project\ 9
  22. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 9$ dir
  23. lib  project1  project1.lpi  project1.lpr  project1.lps
  24. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 9$ fpc ./project1.lpr
  25. Free Pascal Compiler version 3.2.0 [2020/07/07] for x86_64
  26. Copyright (c) 1993-2020 by Florian Klaempfl and others
  27. Target OS: Linux for x86-64
  28. Compiling ./project1.lpr
  29. Linking project1
  30. 25 lines compiled, 0.4 sec
  31. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 9$ dir
  32. lib  project1  project1.lpi  project1.lpr  project1.lps  project1.o
  33. pascal@pascal-Lenovo-ideapad-330-15AST:~/Computer/Lazarus/Lazarus Projects/Studying Projects/Common/Project 9$ ./project1
  34. ?? ???? ????? ???????
  35. ???? ???? ????? ???? ????? ???????
  36. ???? ????? ??? ???????? ??? ???? ?? ????????? ?? ??? ??? ?????? ?? ?? ?????? ????? ?? ???????!
  37.  
  38. Do you read the current line?
  39. What do you find? Words, and do you see them well?
  40. What do these words say? It is nothing more than asking if you are reading it or not, it is something out of nothing!
  41.  
  42.  
« Last Edit: May 11, 2021, 08:34:13 pm by pascal111 »

engkin

  • Hero Member
  • *****
  • Posts: 2819
Re: Displaying Arabic on Console
« Reply #7 on: May 11, 2021, 10:58:30 pm »
Can you check if the number of question marks matches the number of letters in each word?

If they match, I suggest the problem is in the font.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #8 on: May 11, 2021, 11:10:50 pm »
Can you check if the number of question marks matches the number of letters in each word?

If they match, I suggest the problem is in the font.

لقد قُمتُ بعد علامات الإستفهام بعد تغيير العبارات لعبارة أقصر ليكون حلّكـ عمليّاً فكانت علامات الإستفهام على نفس عدد حروف العبارة. أظنّ كما قلتَ أنّ المشكلة في الخط ولكن كيف يُمكن تغيير الخط أو ضبطه هنا؟


google translate:

"I followed "counted" the question marks after changing the phrases for a shorter phrase to make your solution practical, so the question marks were the same number of letters of the sentence "word". I think, as you said, the problem is in the line "font", but how can "I change or adjust" the font be changed or set here?"

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4. {$codepage utf8}
  5.  
  6. uses
  7.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  8.   cthreads,
  9.   {$ENDIF}{$ENDIF}
  10.   Classes
  11.   { you can add units after this };
  12.  
  13. begin
  14.  
  15.   {writeln('هل تقرأ السطر الحالي؟');
  16.   writeln('ماذا تجد؟ كلمات ،وهل تراها جيّداً؟');
  17.   writeln('ماذا تقولُ هذه الكلمات؟ ليس أكثر من الإستفسار عن إذا كنت تقرؤها أم لا ،إنّها الشيء من اللاشيء!');
  18.  
  19.   writeln;
  20.  
  21.   writeln('Do you read the current line?');
  22.   writeln('What do you find? Words, and do you see them well?');
  23.   writeln('What do these words say? It is nothing more than asking if you are reading it or not, it is something out of nothing!');}
  24.  
  25.   writeln('مرحبا');
  26. end.
  27.  
  28.  
  29.  


(https://i.postimg.cc/v17M42jk/Screenshot-at-2021-05-11-23-05-27.png)

engkin

  • Hero Member
  • *****
  • Posts: 2819
Re: Displaying Arabic on Console
« Reply #9 on: May 11, 2021, 11:39:45 pm »
I am a Windows user, don't know how to do that on Linux.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #10 on: May 11, 2021, 11:50:10 pm »
I am a Windows user, don't know how to do that on Linux.

ولكنّكـ تعلم إقتراح عد أحرف كلمات عربيّة غير مفرقة الأحرف وبها علامات إعراب لا تظهر بشكل جيّد على أحرفها وفواصل وعلامات ترقيم ومسافات.

هل تستوعب ما قلتُ أم الترجمة غير واضحة ولو كتبتها لكـ بالإنجليزيّة فهل ستقول أنّ إنجليزيتي غير مفهومة؟

google translate:

"However, you know the suggestion of counting letters in "of" Arabic words that are not separated by letters and have accent marks that do not appear well on their letters, commas, punctuation marks, and spaces.

Do you understand what I said, or the translation is not clear, and if I wrote it for you in English, would you say that my English is not understood?"

engkin

  • Hero Member
  • *****
  • Posts: 2819
Re: Displaying Arabic on Console
« Reply #11 on: May 12, 2021, 12:07:24 am »
I do understand your replies. First you confirmed the match between the number of letters and the corresponding question marks. Next you asked how to change the font. My previous reply was to admit to the fact that I do not know how to change the font used in terminal/console window on Linux. Hopefully a more knowledgeable member will point out the way to change the font.

pascal111

  • Sr. Member
  • ****
  • Posts: 282
  • Un trabajo en equipo para programas serias.
Re: Displaying Arabic on Console
« Reply #12 on: May 12, 2021, 12:20:16 am »
I do understand your replies. First you confirmed the match between the number of letters and the corresponding question marks. Next you asked how to change the font. My previous reply was to admit to the fact that I do not know how to change the font used in terminal/console window on Linux. Hopefully a more knowledgeable member will point out the way to change the font.


معكـ حق فيبدو أنّ لغتكـ الأصليّة ليست الإنجليزيّة النقيّة ﻷنّ الرجل الإنجليزي يتفهّم العربيّة الخام.

العربيّة النقيّة غامضة مثل الإنجليزيّة النقيّة.

عموماً إفترضتُ أنّهُ لمّا إقترحتَ إقتراحكـَ أنّ في جُعبتكـ الحل كذلكـ إنْ صدقكـ ظنّكـ وكانت المشكلة هي في نوع الخط ﻷنّكـ ما كُنت لتعرض إقتراحاً كهذا لو لم تكن تعلم الحل في الخطوة التالية لصدق الأمر المُحتمل.

google translate:

"You are right, it seems that your native language is not pure English, because the Englishman understands raw Arabic.

Pure Arabic is as ambiguous as pure English.

In general, I assumed that when you suggested your suggestion that you also have a solution in your pocket, if you "your thought" believed you "became true", and the problem was in the type of line "font", because you would not have presented such a proposal "suggestion" if you had not known the solution in the next step, "of" the possible matter would be validated."

engkin

  • Hero Member
  • *****
  • Posts: 2819
Re: Displaying Arabic on Console
« Reply #13 on: May 12, 2021, 12:48:01 am »
Usually a problem similar to yours is going to be caused by one of two possible reasons:
1-Wrong code page.
2-A font that does not include the correct glyphs.

This is logical and not related to the OS, Windows or Linux.

The same way you assumed I have the solution, I also assumed you know how to change the font, or at least to look it up and learn how to do that.
« Last Edit: May 12, 2021, 12:52:53 am by engkin »

engkin

  • Hero Member
  • *****
  • Posts: 2819
Re: Displaying Arabic on Console
« Reply #14 on: May 12, 2021, 12:57:39 am »
Which distribution of Linux are you using?
I just did a quick search and changing the font seems fairly easy.

 

TinyPortal © 2005-2018