[Gambas-user] How to print Greek

Doriano Blengino doriano.blengino at ...1909...
Sat Feb 13 18:06:01 CET 2010


Vassilis K ha scritto:
> Merci Fabien,
>
> With this routine I get some characters printed but not the Greek ones!
>
> I also tried the conv(tEpitheto.Text, "UTF-8", "xxxx")
> where xxxx was the following char type:
>
> windows-1253, ibm869 : I got output but not in Greek
>
> ibm737,cp-850,cp850,cp-851,ibm869,x-EBCDIC-GreekModern, x-EBCDIC-Greek, iso-8859-3,
> iso-8859-15, ibm850 :  I got Bad string conversion error
>
> I think that the self-made routine is the only road.
> Any ideas how to start?
>   
Where did you take those ibm737 and cp850? I think that those codepages 
must be installed in the system - are they? If not, "bad string 
conversion error" comes from there. I really don't know how to install 
new codepages, it is distribution-dependent, but may be 
"dpkg-reconfigure locale" does something on Debian and Ubuntu systems. 
Anyway, you should check the printer manual to see if there is a name.

While I am writing this, a message from Charlie has some information - I 
stop.

About making a conversion subroutine, you should check what code have 
your characters to print. Are they encoded in UTF-8 or in iso-8859-7? In 
the first case, you should use string.xxx() functions to obtain a 
numeric value, in the second case an asc() would do. Graphics toolkit 
work in UTF-8, so the first case is more likely. Then you create an 
array of chars, or strings, and fill it with single chars to send to the 
printer. Saying that "omega" has a code of 1420 in UTF-8 (not true - 
just to speak), then the element number 1420 of this array should 
contain the ascii value, say, 151, which makes the printer print an 
omega. Then, every time you want to print, you take a single string 
character by character, look it up through the array, and send the 
resulting character to the printer. You can save time by only filling 
cells with greek characters, and leave the other empty. If, when 
scanning the string to print, you encounter a normal, ascii character, 
you look up in the array and, if nothing found, you print the character 
as it is. If, instead, you find a value, then that value is the one to 
send to the printer.

Hope this helps,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list