Converting linefeeds to ebcdic

S

Steve Rainbird

When writing to an ebcdic file using the following code

Sting buf = "\n";
byte [] b = buf.getBytes("cp1047");
write(b);

The linefeed x"0A" is being converted to a new line x"15" not kept as a
linefeed x"25" as i would expect.

Does anybody know a way around this?
 
S

Steve Rainbird

Steve Rainbird said:
When writing to an ebcdic file using the following code

Sting buf = "\n";
byte [] b = buf.getBytes("cp1047");
write(b);

The linefeed x"0A" is being converted to a new line x"15" not kept as a
linefeed x"25" as i would expect.

Are you sure that's not what you want? Many EBCDIC systems use the NEXT
LINE
(0x15) character to signify end-of-line, so for most ASCII files you'd
want
ASCII LINEFEED to translate to EBCDIC NEXT LINE, rather than to EBCDIC
LINEFEED.

Yes i definitely need 0x25 its a Unisys system its going to.
You could try using codepage 37 rather than 1047 in the getBytes( )
call --
that might have slightly different conversion rules.

I will have a look at that thanks.
 
R

Roedy Green

The linefeed x"0A" is being converted to a new line x"15" not kept as a
linefeed x"25" as i would expect.

there are a gazillion EBCDIC variants.


If you can't find a built in one that does what you want, here is how
you might proceed.

1. decompile the closest one you can find. see
http://mindprod.com/jgloss/decompiler.html

2. modify it.

3. Instantiate it.

4. use encode/decode that take a CharSet object instead of an encoding
string name. See http://mindprod.com/jgloss/encoding.html

5. see if you can find a mechanism to build in your new encoding.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Nature provides a free lunch, but only if we control our appetites."
~ William Ruckelshaus, America’s first head of the EPA
 
R

Roedy Green

Does anybody know a way around this?

The other way to handle this is just to write some application code
that in essence has a char array indexed by char for the translation.

--
Roedy Green Canadian Mind Products
http://mindprod.com

"Nature provides a free lunch, but only if we control our appetites."
~ William Ruckelshaus, America’s first head of the EPA
 
S

Steve Rainbird

Roedy Green said:
there are a gazillion EBCDIC variants.


If you can't find a built in one that does what you want, here is how
you might proceed.

1. decompile the closest one you can find. see
http://mindprod.com/jgloss/decompiler.html

2. modify it.

3. Instantiate it.

4. use encode/decode that take a CharSet object instead of an encoding
string name. See http://mindprod.com/jgloss/encoding.html

5. see if you can find a mechanism to build in your new encoding.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Nature provides a free lunch, but only if we control our appetites."
~ William Ruckelshaus, America's first head of the EPA

thanks Roedy
 
A

Arne Vajhøj

Steve said:
When writing to an ebcdic file using the following code

Sting buf = "\n";
byte [] b = buf.getBytes("cp1047");
write(b);

The linefeed x"0A" is being converted to a new line x"15" not kept as a
linefeed x"25" as i would expect.

Does anybody know a way around this?

Use one of:

Cp933
Cp1097
Cp1140
Cp1141
Cp1142
Cp1143
Cp1144
Cp1145
Cp1146
Cp1147
Cp1148
Cp1149

(you will need to find the right one yourself - this is just those that
convert 0x0A to 0x25)

Arne
 
S

Steve Rainbird

Arne Vajhøj said:
Steve said:
When writing to an ebcdic file using the following code

Sting buf = "\n";
byte [] b = buf.getBytes("cp1047");
write(b);

The linefeed x"0A" is being converted to a new line x"15" not kept as a
linefeed x"25" as i would expect.

Does anybody know a way around this?

Use one of:

Cp933
Cp1097
Cp1140
Cp1141
Cp1142
Cp1143
Cp1144
Cp1145
Cp1146
Cp1147
Cp1148
Cp1149

(you will need to find the right one yourself - this is just those that
convert 0x0A to 0x25)

Arne
Thanks Arne.
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top