Board index » delphi » Euro character

Euro character

For a billing program I need to print the Euro (money) character. This
character is not yet a standard ASCII character so I have to make
something up. My quick and dirty solution sofar is to print the capital
'C' the backspace character '#8' and the equal sign '=' so on paper the
'=' is printed on top of the 'C'
In Pascal;
...
WRITE (lst,'C',#8,'= ',amount);
...
but I find this looks not good enough.
I know that my (HP) printer supports 'user defined' or 'downloadable'
characters but the printer manual is not clear on how to do this.

Did anyone out here do something similar? If so, please share with me.

--
Martin

 

Re:Euro character


In article <368ACA7B.7...@inter.nl.net>,
G.Velema / M. Hilvers <NOSPAMgvel...@inter.NL.net> wrote:

Quote
>For a billing program I need to print the Euro (money) character. This
>character is not yet a standard ASCII character so I have to make
>something up.

The American Standard Code for Information Interchange has been fixed
for long and it has the 95 printable characters it has and nothing will
be added.

Quote
> My quick and dirty solution sofar is to print the capital
>'C' the backspace character '#8' and the equal sign '=' so on paper the
>'=' is printed on top of the 'C'
>In Pascal;
>...
>WRITE (lst,'C',#8,'= ',amount);

Each currency has a specific abbreviation that is written for normal
letters, like USD for US dollars or FIM for Finnish marks. Check what
the abbreviation for euro is and use it.

Osmo

Re:Euro character


JRS:  In article <76g51v$...@myntti.helsinki.fi> of Thu, 31 Dec 1998
17:25:51 in news:comp.lang.pascal.borland, Osmo Ronkanen

Quote
<ronka...@cc.helsinki.fi> wrote:
>In article <368ACA7B.7...@inter.nl.net>,
>G.Velema / M. Hilvers <NOSPAMgvel...@inter.NL.net> wrote:
>>For a billing program I need to print the Euro (money) character. This
>>character is not yet a standard ASCII character so I have to make
>>something up.

>The American Standard Code for Information Interchange has been fixed
>for long and it has the 95 printable characters it has and nothing will
>be added.

>> My quick and dirty solution sofar is to print the capital
>>'C' the backspace character '#8' and the equal sign '=' so on paper the
>>'=' is printed on top of the 'C'
>>In Pascal;
>>...
>>WRITE (lst,'C',#8,'= ',amount);

>Each currency has a specific abbreviation that is written for normal
>letters, like USD for US dollars or FIM for Finnish marks. Check what
>the abbreviation for euro is and use it.

See http://www.merlyn.demon.co.uk/eurocash.htm for some non-financial
Euro answers, including that one, which is EUR.

Osmo is only technically right; just because the Americans have a
standard does not mean that they, especially MS, will pay any attention
to it.

        WRITE (lst,'C'#8'= ',amount);
saves two commas in Source, and, ISTM, $F bytes of code.

--
John Stockton, Surrey, UK.   j...@merlyn.demon.co.uk    JR.Stock...@physics.org
  Web <URL: http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
  Correct 4-line sig. separator is as above, a line precisely "-- " (SoRFC1036)
  Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

Re:Euro character


G.Velema / M. Hilvers wrote:

Quote
> For a billing program I need to print the Euro (money) character. This
> character is not yet a standard ASCII character so I have to make
> something up. My quick and dirty solution sofar is to print the capital
> 'C' the backspace character '#8' and the equal sign '=' so on paper the
> '=' is printed on top of the 'C'
> In Pascal;
> ...
> WRITE (lst,'C',#8,'= ',amount);
> ...
> but I find this looks not good enough.
> I know that my (HP) printer supports 'user defined' or 'downloadable'
> characters but the printer manual is not clear on how to do this.

> Did anyone out here do something similar? If so, please share with me.

> --
> Martin

This is just an idea but maybe you could try creating it as a bit-mapped
character or a user defined character.  I know Turbo Pascal has the
capability but I am not an expert on how to do it.  The only problem I can
see is that you will have to come up with a comparable print routine when
it come to sending it to the printer.

Hope this helps somewhat.

David Solly

Re:Euro character


On 31 Dec 1998 17:25:51 +0200, ronka...@cc.helsinki.fi (Osmo Ronkanen)
wrote:

Quote
>In article <368ACA7B.7...@inter.nl.net>,
>G.Velema / M. Hilvers <NOSPAMgvel...@inter.NL.net> wrote:
>>For a billing program I need to print the Euro (money) character. This
>>character is not yet a standard ASCII character so I have to make
>>something up.

>The American Standard Code for Information Interchange has been fixed
>for long and it has the 95 printable characters it has and nothing will
>be added.

Roll on unicode :)

Re:Euro character


On Wed, 30 Dec 1998 23:51:07 -0100, G.Velema / M. Hilvers

Quote
<NOSPAMgvel...@inter.NL.net> wrote:
>For a billing program I need to print the Euro (money) character.
...
>I know that my (HP) printer supports 'user defined' or 'downloadable'
>characters but the printer manual is not clear on how to do this.

Hi Martin -

The following program will create a little file called EUROCHAR.PCL, which
will generate and print the Euro mark in a bit of sample text. You will
need to send it to your printer with a command like:

   copy /b eurochar.pcl lpt1

You will need to study the program and see how I created it, then adapt
those techniques to your own program.

I drew the character initially as a text bitmap (technically it's more of a
"byte-map"). I then wrote a little routine to convert this into a real
binary bitmap which is what eventually gets sent to the printer. I sent it
as the contents of a PCL macro so it can be called multiple times per print
job.

The character is in a 32x32 pixel bitmap, which when printed at 300dpi
resolution, will occupy just over 1/10 of an inch, which will be okay if
you're printing at 10cpi in a fixed width font such as Courier (I only
tested it with default printer settings). If you are printing at a
different pitch, or are using a proportional font, you may need to make
some adjustments to things.

Let me know if you have questions about any of this.

Cheers, Todd  

-8<--------------------------------------------------------------------------
{---------------------------------------------------------------------------}
{- EUROCHAR.PAS    generate HP PCL code to print the Euro currency symbol  -}
{- Todd Fiske      tfi...@delphi.com                                       -}
{-                                                                         -}
{- 1999-01-05      first version                                           -}
{---------------------------------------------------------------------------}

{----------------------------------------------------------------------------

This program defines a bitmap to resemble the Euro currency character, and
provides routines to convert it into HP PCL code so that it can be printed
along with other text.

The approach is to send the character as Raster Data, and wrap the raster
data in a PCL macro which takes care of cursor positioning so that the
character can be printed with relative ease. "Relative" since PCL printing is
always a bit finicky to begin with.

----------------------------------------------------------------------------}

program eurochar;

const
   CharBitmap : array [ 0..31, 0..31 ] of char =

     {          11111111112222222222333 }
     { 12345678901234567890123456789012 }
   (
      '................................', {  1 }  { This is my crude repre- }
      '................................', {  2 }  { sentation of the Euro   }
      '................................', {  3 }  { symbol, based on what I }
      '.................xxxxxx.........', {  4 }  { saw on the Europa web   }
      '...............xxxxxxxxxx.......', {  5 }  { page.                   }
      '.............xxxxxxxxxxxxxx.....', {  6 }
      '...........xxxxxxx....xxxxxx....', {  7 }
      '.........xxxxxx..........xxxxx..', {  8 }
      '........xxxxx.............xxxxx.', {  9 }
      '.......xxxxx................xxx.', { 10 }  { Use an "x" for a black  }
      '.......xxxx..................x..', { 11 }  { pixel, and a "." for a  }
      '......xxxx......................', { 12 }  { clear pixel, and modify }
      '..xxxxxxxxxxxxxxxxxxxxxxxxxx....', { 13 }  { the bitmap to properly  }
      '.xxxxxxxxxxxxxxxxxxxxxxxxxx.....', { 14 }  { reflect the mark.       }
      'xxxxxxxxxxxxxxxxxxxxxxxxxx......', { 15 }
      '....xxxx........................', { 16 }
      '....xxxx........................', { 17 }
      '..xxxxxxxxxxxxxxxxxxxxx.........', { 18 }
      '.xxxxxxxxxxxxxxxxxxxxx..........', { 19 }  { You can change the      }
      'xxxxxxxxxxxxxxxxxxxxx...........', { 20 }  { black and clear pixel   }
      '......xxxx......................', { 21 }  { characters to be what-  }
      '......xxxxx..................x..', { 22 }  { ever you like, but make }
      '.......xxxxx................xxx.', { 23 }  { sure to change ALL of   }
      '........xxxxx.............xxxxx.', { 24 }  { them, and change the    }
      '.........xxxxxx..........xxxxx..', { 25 }  { zero_char and one_char  }
      '..........xxxxxxxx....xxxxxxx...', { 26 }  { constants below to      }
      '............xxxxxxxxxxxxxxx.....', { 27 }  { match.                  }
      '..............xxxxxxxxxxx.......', { 28 }
      '.................xxxxxx.........', { 29 }
      '................................', { 30 }
      '................................', { 31 }
      '................................'  { 32 }
   );

var
   CharArray : array [ 0..127 ] of byte;  { this will hold the binary       }
                                          { version of the above bitmap -   }
                                          { see convert_bitmap_to_array()   }

{- This could also be defined as "array [ 0..31, 0..3 ] of byte", but my
initial attempt was to redefine a character in a font, where the binary data
appears all as one sequence (using raster data, each raster line is sent
separately). In any event, the array access is similar either way, so I left
it as is.
-}

{---------------------------------------------------------------------------}

{- The following definitions and routines provide a simple way to convert a
byte into a binary string representation and vice versa. For example:

   AByte   := ord( 'T' );
   AString := byte2bit( AByte );

   AString now contains '.x.x.x..'

byte2bit() is not used in this program. bit2byte() is used to convert the
text bitmap above into binary data to be sent to the laser printer.

Real2Str() is used by the demo in write_pcl() below. It's not used by the
bit/byte conversion routines, I just like to put all of my "library-level"
routines together.

Iifc() returns one of two characters depending on the given boolean. It is
used by byte2bit().

Redefine the constants zero_char and one_char if you want, or use the
routines set_zero_char() and set_one_char(). I use "." for 0 and "x" for 1
because they come pretty close to clear and filled pixels respectively.
-}

const
   zero_char : char = '.';
   one_char  : char = 'x';

type
   string_8  = string[ 8 ];

{------------------------------------------------------------------------------}
{- Real2Str                                                                   -}
{------------------------------------------------------------------------------}
function real2str( r : real; l, d : integer ) : string;
var
   s : string;
begin
   str( r : l : d, s );
   real2str := s;
end;

{---------------------------------------------------------------------------}
{- Iifc                                                                    -}
{---------------------------------------------------------------------------}
function iifc( b : boolean; c1, c2 : char ) : char;
begin
   if b then
      iifc := c1
   else
      iifc := c2;
end;

{---------------------------------------------------------------------------}
{- Set Zero Char                                                           -}
{---------------------------------------------------------------------------}
procedure set_zero_char( c : char );
begin
   if c <> one_char then
      zero_char := c;
end;
procedure set_one_char( c : char );
begin
   if c <> zero_char then
      one_char := c;
end;

{---------------------------------------------------------------------------}
{- Bit2Byte                                                                -}
{---------------------------------------------------------------------------}
function bit2byte( s : string_8 ) : byte;
var
   i, j, w : byte;
begin
   i := 128;
   j := 1;
   w := 0;
   for j := 1 to 8 do begin
      if s[ j ] = one_char then
         w := w + i;
      i := i shr 1;
   end;
   bit2byte := w;
end;

{---------------------------------------------------------------------------}
{- Byte2Bit                                                                -}
{---------------------------------------------------------------------------}
function byte2bit( b : byte ) : string_8;
var
   i : byte;
   j : byte;
   w : string_8;
begin
   i := 128;
   w := '';
   j := 1;
   while i > 0 do begin
      w[ j ] := iifc( ( b and i ) = i, one_char, zero_char );
      i := i shr 1;
      inc( j );
   end;
   w[ 0 ] := #8;
   byte2bit := w;
end;

{---------------------------------------------------------------------------}

{---------------------------------------------------------------------------}
{- Convert Bitmap To Array                                                 -}
{---------------------------------------------------------------------------}
procedure convert_bitmap_to_array;
var
   rind : word; { bitmap row index }
   cind : word; { bitmap column index }
   aind : word; { array index }

   s : string_8;
   b : byte;
begin
   {- for each row of bitmap
         for each octet of row
            convert octet to byte
            put byte in array
   -}

   aind := 0;
   rind := 0;
   while rind < 32 do begin                      { for each row of bitmap }

      cind := 0;
      while cind < 32 do begin                   { for each octect of row }

         move( CharBitmap[ rind, cind ], s[ 1 ], 8 ); { copy data to string }
         s[ 0 ] := #8;                           { set string length }

         b := bit2byte( s );                     { convert string to byte }
         CharArray[ aind ] := b;                 { put byte in array }

         inc( aind );                            { advance array }
         inc( cind, 8 );                         { advance column by 8 }
      end;

      inc( rind );                               { advance row }
   end;
end;
...

read more »

Re:Euro character


In article <76uerb$...@lotho.delphi.com>,
  tfi...@delphi.com (Todd Fiske) wrote:

Quote
> On Wed, 30 Dec 1998 23:51:07 -0100, G.Velema / M. Hilvers
> <NOSPAMgvel...@inter.NL.net> wrote:

> >For a billing program I need to print the Euro (money) character.
> ...
> >I know that my (HP) printer supports 'user defined' or 'downloadable'
> >characters but the printer manual is not clear on how to do this.

> Hi Martin -

> The following program will create a little file called EUROCHAR.PCL, which
> will generate and print the Euro mark in a bit of sample text. You will
> need to send it to your printer with a command like:

>    copy /b eurochar.pcl lpt1

> You will need to study the program and see how I created it, then adapt
> those techniques to your own program.

> I drew the character initially as a text bitmap (technically it's more of a
> "byte-map"). I then wrote a little routine to convert this into a real
> binary bitmap which is what eventually gets sent to the printer. I sent it
> as the contents of a PCL macro so it can be called multiple times per print
> job.

> The character is in a 32x32 pixel bitmap, which when printed at 300dpi
> resolution, will occupy just over 1/10 of an inch, which will be okay if
> you're printing at 10cpi in a fixed width font such as Courier (I only
> tested it with default printer settings). If you are printing at a
> different pitch, or are using a proportional font, you may need to make
> some adjustments to things.

> Let me know if you have questions about any of this.

<Program snipped>

Of course this is a very neat solution, but...

why don't you simply use the ISO currency code for euro, "EUR", which is pure
standard ASCII and can be produced by every device?

Robert
--
Robert AH Prins
prin...@williscorroon.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Re:Euro character


Quote
In article <76uerb$...@lotho.delphi.com>, Todd Fiske <tfi...@delphi.com> wrote:
>The character is in a 32x32 pixel bitmap, which when printed at 300dpi
>resolution, will occupy just over 1/10 of an inch, which will be okay if
>you're printing at 10cpi in a fixed width font such as Courier (I only
>tested it with default printer settings).

How can it be OK if it is too wide? Lets say you need to print 10 of
those in a row, your characters will be 1.7 mm off.

Quote
> If you are printing at a
>different pitch, or are using a proportional font, you may need to make
>some adjustments to things.

In case of proportional font any width works by definition. One just has
to know the width.

Not all PCL printers support macros so it is better to do the job in the
computer. Sending 128 bytes is not that hard.

Osmo

Re:Euro character


Quote
Robert AH Prins wrote:
> ...
> why don't you simply use the ISO currency code for euro, "EUR"...

There are symbols for the Dollar, the Pound, the Yen and maybe more. I
am just (a bit) chauvinistic about this.

---> I want my Euro symbol !! <---

and certainly if it can be done in a (Pascal)program.

Thanks for the contributions so far (how can it be done for an Epson
matrix printer?)

--
Martin H

Re:Euro character


There happens to be a euro patch lingering on the net, which will patch
up the character files of your system.

So with the right <alt> key sequence .....

Greetings

Quote
M. Hilvers wrote:

> Robert AH Prins wrote:
> > ...
> > why don't you simply use the ISO currency code for euro, "EUR"...

> There are symbols for the Dollar, the Pound, the Yen and maybe more. I
> am just (a bit) chauvinistic about this.

> ---> I want my Euro symbol !! <---

> and certainly if it can be done in a (Pascal)program.

> Thanks for the contributions so far (how can it be done for an Epson
> matrix printer?)

> --
> Martin H

Re:Euro character


In article <3693D9E4.5...@inter.NL.net>,

Quote
  NOSPAMgvel...@inter.NL.net wrote:
> Robert AH Prins wrote:
> > ...
> > why don't you simply use the ISO currency code for euro, "EUR"...

> There are symbols for the Dollar, the Pound, the Yen and maybe more. I
> am just (a bit) chauvinistic about this.

Chauvinistic about a symbol tought up by faceless burocrats???

Quote
> ---> I want my Euro symbol !! <---

> and certainly if it can be done in a (Pascal)program.

> Thanks for the contributions so far (how can it be done for an Epson
> matrix printer?)

Robert
--
Robert AH Prins
prin...@williscorroon.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

Re:Euro character


On 6 Jan 1999 10:29:54 +0200, Osmo Ronkanen <ronka...@cc.helsinki.fi> wrote:

Quote
>How can it be OK if it is too wide? Lets say you need to print 10 of
>those in a row, your characters will be 1.7 mm off.

Hi Osmo -

That's just plain whacky! Anyone who needs to print 10 of these in a row is
already out of their tree, and I'm certainly not writing this program for
THEM!! (just kidding =)

The character cell is 32 dots wide, and the character itself is 31 dots
wide (there is one blank column of dots at the right edge). This may
overlap the following character cell by 1 dot, but most characters aren't
flush left in their character cell anyway, so the chance of a real dot
"collision" is pretty slim. (could happen though)

Further, the character cell may be 32 dots wide, but the cursor position is
advanced by the width of a space, so there will be no error accumulation,
even in the (admittedly whacky) event that someone wants to print ten of
these in a row.

Notice near the end of the macro definition:

   send( cEsc + '&f1S' ); { restore (pop) cursor position }
   send( ' ' );           { write a space to move beyond Euro mark }

Drawing raster graphics does not change the cursor position, so I have to
advance it myself. (I have to push it first and move it into position since
characters are drawn relative to their baseline, but graphics are drawn
from their top left corner). To make this work with a proportional font,
one could use <esc> *p+32X (advance cursor horizontally by dots).

Quote
>>If you are printing at a different pitch, or are using a proportional
>>font, you may need to make some adjustments to things.

>In case of proportional font any width works by definition. One just has
>to know the width.

Right, as illustrated above. That's why I said "you may need to make some
adjustments". You may not have understood that cursor positioning has to be
done manually, and the solution I initially provided would not work in a
proportional setting. The character would occupy its 31 dots, and the
following space would advance the cursor perhaps 15 or 20 dots, at which
point the next character definitely would overlap the Euro symbol. The
adjustment is the use of the "move by dots" command.

Quote
>Not all PCL printers support macros so it is better to do the job in the
>computer. Sending 128 bytes is not that hard.

Excellent! Left as an exercise for the reader. =)

But here's a suggestion anyway, since it's not just sending 128 bytes, but
32 groups of 4 bytes, each with their leading "bytes are coming" command,
plus the commands to start and finish graphics mode, and the commands to
move the cursor around. So the "no-macro" solution would be to create a
procedure called "send_euro_char" that sends all of the necessary bytes
each time a Euro symbol is needed, and call that instead of invoking the
PCL macro.

Taking your point though, I did wonder if he meant "DeskJet" or perhaps
some only partially PCL compatible printer, and wondered which parts of
this solution would or would not work for him, but decided to continue
since there's the chance that all of it would work, and it was just good
gosh darn fun anyway. So as I said above, any further adjustments are
LAAEFTR, but I'm happy to provide more suggestions. Also always happy to
receive critiques such as yours.

Cheers, Todd

Re:Euro character


On Wed, 06 Jan 1999 08:29:15 GMT, Robert AH Prins <prin...@williscorroon.com>
wrote:

Quote
>Of course this is a very neat solution, but...

Thank you.

Quote
>why don't you simply use the ISO currency code for euro, "EUR", which is pure
>standard ASCII and can be produced by every device?

Because (choose one or more):

   a> many people had already suggested that.

   b> I relish the opportunity to play with and share my knowledge of
      graphics and PCL programming (I mustard it also).

   c> my way is more fun. =)

   d> my way is actually a more direct answer to the original poster's
      question about creating user-defined characters.

   e> my way illustrates that it is possible for 7-bit-character-set-bound
      programmers to use fancy new international symbols in their programs.

   f> sometimes it's worth knowing how to jump through hoops even when you
      don't have to, and it's also worth trying to do something "hard" just
      for the practice.

Thanks for asking. <g>

Cheers, Todd

Re:Euro character


On Wed, 06 Jan 1999 20:47:16 -0100, M. Hilvers <NOSPAMgvel...@inter.NL.net>
wrote:

Quote
>Robert AH Prins wrote:
>> why don't you simply use the ISO currency code for euro, "EUR"...
>There are symbols for the Dollar, the Pound, the Yen and maybe more. I
>am just (a bit) chauvinistic about this.

>---> I want my Euro symbol !! <---

Hi Martin -

I knew I forgot a reason. =)

Quote
>how can it be done for an Epson matrix printer?

Which kind? I have a manual for a Panasonic KX-P1124 which emulates the
Epson LQ-2500. The Panasonic itself supports a feature called "down line
load characters" if you have the extra memory option. With this you can
design and print any character you like along with normal text output. If
the Epson you have in mind supports this capability, or some variation of
it, it will be relatively easy to print the Euro symbol on it.

If not, the only other way that occurs to me is to send the character as an
actual graphic image. This means lining it up correctly with text data,
possibly double printing the page. You of course could print the entire
page as graphics, in which case the Euro is just one more bitmap, but
printing will be very slow.

Cheers, Todd

Re:Euro character


Quote
Todd Fiske wrote:
> ...Excellent! Left as an exercise for the reader. =)

> ... I did wonder if he meant "DeskJet" or perhaps
> some only partially PCL compatible printer, and wondered which parts of
> this solution would or would not work for him, but decided to continue
> since there's the chance that all of it would work, and it was just good
> gosh darn fun anyway. So as I said above, any further adjustments are
> LAAEFTR, but I'm happy to provide more suggestions.
> ...

I tried your program in TP7, it compiles and runs ok - it pruduces the
eurochar.pcl file as it should.
If I send that file to the printer (HP Deskjet 670C) it produces a neat
single Euro character on an otherwise empty page, and a second page with
the test lines - without the Euro char.

Thanks sofar.

--
MH

Go to page: [1] [2]

Other Threads