|
-
Jun 11th, 2003, 10:54 AM
#1
Thread Starter
Fanatic Member
Convert EBCDIC to ASCII format
Hi
I have a print file that has been generated from an IBM AS/400 system. I need to convert the EBCDIC format file into ASCII format. Is there any method in .NET framework that I can use to easily convert my file. I'm using VB.NET. If I have to write my own conversion function can someone give me a few ideas please.
Thanks
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Jun 14th, 2003, 02:13 AM
#2
Thread Starter
Fanatic Member
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Jun 14th, 2003, 03:47 AM
#3
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jun 14th, 2003, 07:26 AM
#4
Thread Starter
Fanatic Member
Thanks dynamic_sysop.
Unfortunately the Microsoft link is not very helpful. I have also realised that I cannot read my EBCDIC file as a text file. In VB6 I using the TextStream from FileSystemObject to read 133 characters (represneting a line) into a string and then passing that string to a library method for conversion.
My problem is two fold.
1. I have a VB6 library which I can reference from my VB.NET app but I need to pass it a string.
2. I can't read my EBCDIC file as a text file. ReadLine methods fail.
Any suggestions of how to tackle this.
Thanks
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Jun 15th, 2003, 03:20 AM
#5
i dont know what format EBCDIC is personally , but you can read most stuff with streamreader, whether the chars return correctly from the opened file depends what you are opening i think but streamreader might allow you to read your file.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jun 15th, 2003, 12:53 PM
#6
Thread Starter
Fanatic Member
dynamic_sysop
EBCDIC is the proprietary IBM format. I did try using StreamReader but unfortunately when I convert the characters read into a string it doesn't come in the format that I expect to pass it on to the VB6 conversion library. I'm probably not giving the right encoding mode while opening the stream and can't figure it out either. I have for the moment opted for a dirty solution which is my last resort and I'll try it tomorrow at the office. I've decided to reference the Scripting.FileSystemObject class (SCRRUN.DLL) in my VB.NET project and then use the Read method of the TextStream to read my EBCDIC file. I hate this solution as I would prefer avoiding any VB6 code in my project.
Thanks for your help.
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Jun 15th, 2003, 03:03 PM
#7
you know you could reference a vb6 dll to your programme and then do your decoding stuff inside the dll , i'm sure you are aware it's very easy to create a vb6 dll , i've built quite a few and referenced them to vb.net ( eg: i find winsock to be rubish , so i built my own custom socket connection through api , i reference that to .net and then all the coding / converting is done inside the vb6 dll ).
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jun 16th, 2003, 01:52 PM
#8
Thread Starter
Fanatic Member
Thanks for your input dynamic_sysop.
Here's how I resolved my problem.
1. Reference the SCRRUN.DLL and instantiate the FileSystemObject class.
2. Reference the VB6 DLL which converts EBCDIC to ASCII
3. Open the file using TextStream
4. Read each fixed record size using oTxtStream.Read(recsize) into a string strEBCDIC
5. Invoke the conversion using
strASCII = objStrLib.EBCDCI2ASCII(strEBCDIC)
And it works now.
In fact I had resolved myself to using the VB6 library but then got stuck on correctly reading the EBCDIC records into a string. After trying all VB.NET streams, various Encoding modes etc. I still couldn't get the correct data in my string variable.
I am still going to do some research and find out the exact equivalent of FSO TextStream.Read in the .NET environment.
Thanks again for your posts.
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Dec 3rd, 2003, 03:59 PM
#9
Lively Member
What is the VB6 dll called
Hey I am having the same issue. I can find the SCCRUN.DLL but I am not sure what the VB6.DLL is called .
Any help would be appreciated
-
Dec 23rd, 2003, 06:06 AM
#10
Thread Starter
Fanatic Member
Hi
Haven't dug further yet but I'm sure the answer lies in proper usage of the StreamReader, BinaryStream etc. How, don't know yet :-(
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Dec 24th, 2003, 11:39 AM
#11
well you could try using the encoding class with encoding.convert , eg:
VB Code:
Dim source As Encoding = Encoding.GetEncoding(37)'///EBCDIC encoding.
Dim path As Encoding = Encoding.ASCII
Dim b As Byte() = path.GetBytes(TextBox1.Text.ToCharArray)
Dim aB As Byte() = Encoding.Convert(source, path, b)
Console.WriteLine(path.GetString(aB))
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|