User Tools

Site Tools


arabic_20text_20on_20the_20mainwin_20and_20printer_20_28lbb_29

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

arabic_20text_20on_20the_20mainwin_20and_20printer_20_28lbb_29 [2018/03/31 13:19]
127.0.0.1 external edit
arabic_20text_20on_20the_20mainwin_20and_20printer_20_28lbb_29 [2018/04/01 08:26] (current)
richardrussell Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, December 2014//\\ \\ [[http://​lbbooster.com/​|LB Booster]] supports **Unicode**,​ so it is possible for a program to contain, and for the mainwin and printer to show, characters from foreign alphabets (Cyrillic, Greek, Arabic, Hebrew etc.) //without// needing to configure your PC for a specific 'code page'. This means that you can write a program which outputs text in one //or more// of these languages such that it will run on **any** (modern) Windows PC, so long as an appropriate font which contains the characters is selected.\\ \\  However, whilst being able to output the necessary characters is sufficient for languages like Russian and Greek, some languages have additional requirements which you may need to take account of in your programs. For example Hebrew is written right-to-left so as well as changing the **character set** you also need to change the **direction** (you might get away with outputting the characters in the reverse order but it's not very satisfactory).\\ \\  Another example is Arabic, which as well as being written right-to-left has a large number of **contextual** character forms which means that the appearance of a character may change according to which other character(s) precede and/or follow it (Arabic is written in a cursive script in which the characters 'run into' each other). In that case you certainly won't get away with simply outputting the characters in reverse order!\\ \\  When outputting to a Windows **GUI control** (such as a textbox) the writing-direction and any special contextual forms are usually taken care of automatically by Windows. The article [[/​Displaying%20Unicode%20text%20in%20a%20control|Displaying Unicode text in a control]] describes the steps you need to take to achieve this. When outputting to the **mainwin** or to the **printer** however there is no such automatic support, but fortunately LBB //does// provide the necessary features to achieve the required effects.\\ \\  In order to switch the output direction to right-to-left (on both the mainwin and the printer) you can send this character sequence:​\\ ​ //by Richard Russell, December 2014//\\ \\ [[http://​lbbooster.com/​|LB Booster]] supports **Unicode**,​ so it is possible for a program to contain, and for the mainwin and printer to show, characters from foreign alphabets (Cyrillic, Greek, Arabic, Hebrew etc.) //without// needing to configure your PC for a specific 'code page'. This means that you can write a program which outputs text in one //or more// of these languages such that it will run on **any** (modern) Windows PC, so long as an appropriate font which contains the characters is selected.\\ \\  However, whilst being able to output the necessary characters is sufficient for languages like Russian and Greek, some languages have additional requirements which you may need to take account of in your programs. For example Hebrew is written right-to-left so as well as changing the **character set** you also need to change the **direction** (you might get away with outputting the characters in the reverse order but it's not very satisfactory).\\ \\  Another example is Arabic, which as well as being written right-to-left has a large number of **contextual** character forms which means that the appearance of a character may change according to which other character(s) precede and/or follow it (Arabic is written in a cursive script in which the characters 'run into' each other). In that case you certainly won't get away with simply outputting the characters in reverse order!\\ \\  When outputting to a Windows **GUI control** (such as a textbox) the writing-direction and any special contextual forms are usually taken care of automatically by Windows. The article [[/​Displaying%20Unicode%20text%20in%20a%20control|Displaying Unicode text in a control]] describes the steps you need to take to achieve this. When outputting to the **mainwin** or to the **printer** however there is no such automatic support, but fortunately LBB //does// provide the necessary features to achieve the required effects.\\ \\  In order to switch the output direction to right-to-left (on both the mainwin and the printer) you can send this character sequence:​\\ ​
 +<code lb>
       print chr$(23);​chr$(16);​chr$(2);​space$(7)       print chr$(23);​chr$(16);​chr$(2);​space$(7)
 +</​code>​
 \\  This should be sufficient to output Hebrew to the printer, for example try this program (remember to enable **Unicode support** in the Options menu):​\\ ​ \\  This should be sufficient to output Hebrew to the printer, for example try this program (remember to enable **Unicode support** in the Options menu):​\\ ​
 +<code lb>
       PrinterFont$ = "Arial 16"       PrinterFont$ = "Arial 16"
       print chr$(23);​chr$(16);​chr$(2);​space$(7) ' right-to-left       print chr$(23);​chr$(16);​chr$(2);​space$(7) ' right-to-left
       lprint "​זוהי הדגמה של כתיבת טקסט בעברית מימין לשמאל"​       lprint "​זוהי הדגמה של כתיבת טקסט בעברית מימין לשמאל"​
       dump       dump
 +</​code>​
 \\  Outputting to the mainwin is basically the same, except that since the text will be written adjacent to the right '​margin'​ you will need to scroll across before you can see anything:​\\ ​ \\  Outputting to the mainwin is basically the same, except that since the text will be written adjacent to the right '​margin'​ you will need to scroll across before you can see anything:​\\ ​
 +<code lb>
       print chr$(23);​chr$(16);​chr$(2);​space$(7) ' right-to-left       print chr$(23);​chr$(16);​chr$(2);​space$(7) ' right-to-left
       print "​זוהי הדגמה של כתיבת טקסט בעברית מימין לשמאל"​       print "​זוהי הדגמה של כתיבת טקסט בעברית מימין לשמאל"​
 +</​code>​
 \\  To circumvent that issue you can set the right margin at a smaller value (here at column 70):​\\ ​ \\  To circumvent that issue you can set the right margin at a smaller value (here at column 70):​\\ ​
 +<code lb>
       print chr$(28);​chr$(0);​chr$(66);​chr$(70);​chr$(0) ' set right margin       print chr$(28);​chr$(0);​chr$(66);​chr$(70);​chr$(0) ' set right margin
       print chr$(23);​chr$(16);​chr$(2);​space$(7) ' right-to-left       print chr$(23);​chr$(16);​chr$(2);​space$(7) ' right-to-left
       print "​זוהי הדגמה של כתיבת טקסט בעברית מימין לשמאל"​       print "​זוהי הדגמה של כתיבת טקסט בעברית מימין לשמאל"​
-\\  We have still not solved the problem of the Arabic contextual forms however. To do that requires a special function **Arabic$()** which is included in the programs below. Firstly to output some Arabic text to the printer (again, remember to enable **Unicode support**):​\\ ​+</​code>​ 
 +\\  We have still not solved the problem of the Arabic contextual forms however. To do that requires a special function **Arabic$()** which is included in the programs below. Firstly to output some Arabic text to the printer (again, remember to enable **Unicode support**):​\\ 
 +<code lb> ​
       PrinterFont$ = "Arial 16"       PrinterFont$ = "Arial 16"
       print chr$(23);​chr$(16);​chr$(2);​space$(7)       print chr$(23);​chr$(16);​chr$(2);​space$(7)
Line 61: Line 70:
       Arabic$ = left$(b$,​len(b$)-1)       Arabic$ = left$(b$,​len(b$)-1)
   end function   end function
 +</​code>​
 \\  And finally some Arabic text sent to the mainwin:​\\ ​ \\  And finally some Arabic text sent to the mainwin:​\\ ​
 +<code lb>
       print chr$(28);​chr$(0);​chr$(66);​chr$(70);​chr$(0)       print chr$(28);​chr$(0);​chr$(66);​chr$(70);​chr$(0)
       print chr$(23);​chr$(16);​chr$(2);​space$(7)       print chr$(23);​chr$(16);​chr$(2);​space$(7)
Line 106: Line 117:
       Arabic$ = left$(b$,​len(b$)-1)       Arabic$ = left$(b$,​len(b$)-1)
   end function   end function
 +</​code>​
 \\  This is what it looks like on-screen (in this case from Windows XP):\\ {{arabicmainwin.gif}} \\  This is what it looks like on-screen (in this case from Windows XP):\\ {{arabicmainwin.gif}}
arabic_20text_20on_20the_20mainwin_20and_20printer_20_28lbb_29.txt · Last modified: 2018/04/01 08:26 by richardrussell