Encoding conversion from UTF to ISO-8859-7

M

MEARTURO

Hello all,

I have a problem with some encoding conversion from UTF to ISO-8859-7 .
My Oracle database uses UTF but some POS printers in the organization
use ISO-8859-7, so I need to print some Greek characters.

This is part of the code:

Charset set7 = Charset.forName("ISO-8859-7");
ByteBuffer BBtext3 = null,

tempDB = rs.getString(1); //The string in Greek. Oracle UTF
BBtext3 = set7.encode(tempDB); //The string in Greek ISO-8859-7

When I debug this code I see that BBtext3 has these values:
[0] = -51
[1] = -59
[2] = -45
and so on

If I add 256 to those numbers I get:
[0] = 205
[1] = 197
[2] = 211
Which are the positions in ISO-8859-7 of the Greek letters of the UTF
text.

If I send the original string to the printer I get '?' because there is
no such thing as character -51.

What am I missing? How can I complete the conversion from UTF to
ISO-8859-7? It seems that I'm half the way.

Thanks a lot for your time.
 
B

Bill Medland

MEARTURO said:
Hello all,

I have a problem with some encoding conversion from UTF to ISO-8859-7 .
My Oracle database uses UTF but some POS printers in the organization
use ISO-8859-7, so I need to print some Greek characters.

This is part of the code:

Charset set7 = Charset.forName("ISO-8859-7");
ByteBuffer BBtext3 = null,

tempDB = rs.getString(1); //The string in Greek. Oracle UTF
BBtext3 = set7.encode(tempDB); //The string in Greek ISO-8859-7

When I debug this code I see that BBtext3 has these values:
[0] = -51
[1] = -59
[2] = -45
and so on

If I add 256 to those numbers I get:
[0] = 205
[1] = 197
[2] = 211
Which are the positions in ISO-8859-7 of the Greek letters of the UTF
text.

If I send the original string to the printer I get '?' because there is
no such thing as character -51.

Huh?
How are you sending 'the original string'? I would expect that the
printer is merely going to receive a string of octets ; it doesn't
matter if we think of them as signed (which java does) or unsigned
(which the printer does); the pattern of bits is the same.
I guess the issue is how to send that byte stream to the printer
without it getting translated.
 
M

MEARTURO

Bill said:
MEARTURO said:
Hello all,

I have a problem with some encoding conversion from UTF to ISO-8859-7 .
My Oracle database uses UTF but some POS printers in the organization
use ISO-8859-7, so I need to print some Greek characters.

This is part of the code:

Charset set7 = Charset.forName("ISO-8859-7");
ByteBuffer BBtext3 = null,

tempDB = rs.getString(1); //The string in Greek. Oracle UTF
BBtext3 = set7.encode(tempDB); //The string in Greek ISO-8859-7

When I debug this code I see that BBtext3 has these values:
[0] = -51
[1] = -59
[2] = -45
and so on

If I add 256 to those numbers I get:
[0] = 205
[1] = 197
[2] = 211
Which are the positions in ISO-8859-7 of the Greek letters of the UTF
text.

If I send the original string to the printer I get '?' because there is
no such thing as character -51.

Huh?
How are you sending 'the original string'? I would expect that the
printer is merely going to receive a string of octets ; it doesn't
matter if we think of them as signed (which java does) or unsigned
(which the printer does); the pattern of bits is the same.
I guess the issue is how to send that byte stream to the printer
without it getting translated.
What am I missing? How can I complete the conversion from UTF to
ISO-8859-7? It seems that I'm half the way.

Thanks a lot for your time.

Hi,

You have a very good point, the printer expects something like 0D 0F A0
etc.

The problem is that I may have a string with characters from the base
character set (ASCII) and from the extended set (Greek) for instance a
street name in Greek + the number of the street. The conversion leaves
the 'number of the street' intact and the bytes representing the greek
letters in -59, which seems to be a relative position from the top of
ISO-8859-7.

Thanks a lot for your suggestion.
 
O

Oliver Wong

MEARTURO said:
Hello all,

I have a problem with some encoding conversion from UTF to ISO-8859-7 .
My Oracle database uses UTF but some POS printers in the organization
use ISO-8859-7, so I need to print some Greek characters.

This is part of the code:

Charset set7 = Charset.forName("ISO-8859-7");
ByteBuffer BBtext3 = null,

tempDB = rs.getString(1); //The string in Greek. Oracle UTF
BBtext3 = set7.encode(tempDB); //The string in Greek ISO-8859-7

When I debug this code I see that BBtext3 has these values:
[0] = -51
[1] = -59
[2] = -45
and so on

If I add 256 to those numbers I get:
[0] = 205
[1] = 197
[2] = 211
Which are the positions in ISO-8859-7 of the Greek letters of the UTF
text.

If I send the original string to the printer I get '?' because there is
no such thing as character -51.

What am I missing? How can I complete the conversion from UTF to
ISO-8859-7? It seems that I'm half the way.

Don't send "the original String". Send the bytes.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top