473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

yEnc decoder

Hi, I'm working on a type of NewsHound program and am stuck on how to
decode the yEnc encoded articles (body).

I tried using Joe Feser's yEnc class but can't seem to get it to work
properly
Not sure whether it's an Encoding.Type problem or not getting the
stream start position right.

In any case here's part of the code with the problem:

__________________________________________________ _______________
Article = 21971499;
nntp1.Send("BODY " + Article.ToString() + "\r\n");
// this line reads stream till line with period only
s = nntp1.Receive(".\r\n");
Stream inMemStream, outMemStream;
inMemStream= new MemoryStream(Encoding.UTF8.GetBytes(s));
outMemStream= new MemoryStream();
inMemStream.Seek(0, 0);
yenc.DecodeFromRawStream(inMemStream, outMemStream);
outMemStream.Seek(0, 0);

StreamReader sr = new StreamReader(outMemStream, Encoding.UTF8);
string ArticleAttachment = sr.ReadToEnd();
__________________________________________________ ____________________

The problem is that the decoded string has only the upper case letters
right but the lower case letters are spaces.
If any one knows of any other components out there that can decode
yEnc please let me know.

Thanks
Marv
Nov 15 '05 #1
3 4510
If my memory serves right, this code should work(I wrote it a long time ago
and I don't know for sure if it was 100% working, I know it was working with
the test files):
byte[] yEncDecodeBlock(byte[] Block)
{
byte x;
byte[] O = new byte[Block.Length];
byte[] Out;
int count = 0;
for (int i=0;i < Block.Length; i++)
{
x = Block[i];
if (x=='\r')
{

i++;
if (Block[i] == '\n')
{
continue;
}
else
{
throw new yEncInvalidFormatException("There was a carriage return
without a linefeed detected");
}
}
else if (x=='=')
{
i++;
byte r = x;
x = Block[i];
O[count] = (byte)(x-64-42);
}
else
{
O[count] = (byte)(x-42);
}
count++;
}
if (count != 0)
{
Out = new byte[count];
Buffer.BlockCopy(O,0,Out,0,count);
return Out;
}
return null;
}
"Marvin Grill" <ma*********@hotmail.com> wrote in message
news:f0**************************@posting.google.c om...
Hi, I'm working on a type of NewsHound program and am stuck on how to
decode the yEnc encoded articles (body).

I tried using Joe Feser's yEnc class but can't seem to get it to work
properly
Not sure whether it's an Encoding.Type problem or not getting the
stream start position right.

In any case here's part of the code with the problem:

__________________________________________________ _______________
Article = 21971499;
nntp1.Send("BODY " + Article.ToString() + "\r\n");
// this line reads stream till line with period only
s = nntp1.Receive(".\r\n");
Stream inMemStream, outMemStream;
inMemStream= new MemoryStream(Encoding.UTF8.GetBytes(s));
outMemStream= new MemoryStream();
inMemStream.Seek(0, 0);
yenc.DecodeFromRawStream(inMemStream, outMemStream);
outMemStream.Seek(0, 0);

StreamReader sr = new StreamReader(outMemStream, Encoding.UTF8);
string ArticleAttachment = sr.ReadToEnd();
__________________________________________________ ____________________

The problem is that the decoded string has only the upper case letters
right but the lower case letters are spaces.
If any one knows of any other components out there that can decode
yEnc please let me know.

Thanks
Marv

Nov 15 '05 #2
Daniel thanks very much for your reply. You are the first person to
add anything intelligent to this thread so far. You are a gentleman.
I'll give it a try and post a reply for others to benefit.

Marv

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message news:<OA*************@TK2MSFTNGP11.phx.gbl>...
If my memory serves right, this code should work(I wrote it a long time ago
and I don't know for sure if it was 100% working, I know it was working with
the test files):
byte[] yEncDecodeBlock(byte[] Block)
{
byte x;
byte[] O = new byte[Block.Length];
byte[] Out;
int count = 0;
for (int i=0;i < Block.Length; i++)
{
x = Block[i];
if (x=='\r')
{

i++;
if (Block[i] == '\n')
{
continue;
}
else
{
throw new yEncInvalidFormatException("There was a carriage return
without a linefeed detected");
}
}
else if (x=='=')
{
i++;
byte r = x;
x = Block[i];
O[count] = (byte)(x-64-42);
}
else
{
O[count] = (byte)(x-42);
}
count++;
}
if (count != 0)
{
Out = new byte[count];
Buffer.BlockCopy(O,0,Out,0,count);
return Out;
}
return null;
}
"Marvin Grill" <ma*********@hotmail.com> wrote in message
news:f0**************************@posting.google.c om...
Hi, I'm working on a type of NewsHound program and am stuck on how to
decode the yEnc encoded articles (body).

I tried using Joe Feser's yEnc class but can't seem to get it to work
properly
Not sure whether it's an Encoding.Type problem or not getting the
stream start position right.

In any case here's part of the code with the problem:

__________________________________________________ _______________
Article = 21971499;
nntp1.Send("BODY " + Article.ToString() + "\r\n");
// this line reads stream till line with period only
s = nntp1.Receive(".\r\n");
Stream inMemStream, outMemStream;
inMemStream= new MemoryStream(Encoding.UTF8.GetBytes(s));
outMemStream= new MemoryStream();
inMemStream.Seek(0, 0);
yenc.DecodeFromRawStream(inMemStream, outMemStream);
outMemStream.Seek(0, 0);

StreamReader sr = new StreamReader(outMemStream, Encoding.UTF8);
string ArticleAttachment = sr.ReadToEnd();
__________________________________________________ ____________________

The problem is that the decoded string has only the upper case letters
right but the lower case letters are spaces.
If any one knows of any other components out there that can decode
yEnc please let me know.

Thanks
Marv

Nov 15 '05 #3
Heh, np, hopefully it still works.
However, you should probably avoid posting so broadly, the general group
would probably have sufficed.
Also, you may want to obfusticate your email addy, there are a few nasty
scanners that will spam you with virii, etc using email addresses hulled
from these groups.
"Marvin Grill" <ma*********@hotmail.com> wrote in message
news:f0**************************@posting.google.c om...
Daniel thanks very much for your reply. You are the first person to
add anything intelligent to this thread so far. You are a gentleman.
I'll give it a try and post a reply for others to benefit.

Marv

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message

news:<OA*************@TK2MSFTNGP11.phx.gbl>...
If my memory serves right, this code should work(I wrote it a long time ago and I don't know for sure if it was 100% working, I know it was working with the test files):
byte[] yEncDecodeBlock(byte[] Block)
{
byte x;
byte[] O = new byte[Block.Length];
byte[] Out;
int count = 0;
for (int i=0;i < Block.Length; i++)
{
x = Block[i];
if (x=='\r')
{

i++;
if (Block[i] == '\n')
{
continue;
}
else
{
throw new yEncInvalidFormatException("There was a carriage return
without a linefeed detected");
}
}
else if (x=='=')
{
i++;
byte r = x;
x = Block[i];
O[count] = (byte)(x-64-42);
}
else
{
O[count] = (byte)(x-42);
}
count++;
}
if (count != 0)
{
Out = new byte[count];
Buffer.BlockCopy(O,0,Out,0,count);
return Out;
}
return null;
}
"Marvin Grill" <ma*********@hotmail.com> wrote in message
news:f0**************************@posting.google.c om...
Hi, I'm working on a type of NewsHound program and am stuck on how to
decode the yEnc encoded articles (body).

I tried using Joe Feser's yEnc class but can't seem to get it to work
properly
Not sure whether it's an Encoding.Type problem or not getting the
stream start position right.

In any case here's part of the code with the problem:

__________________________________________________ _______________
Article = 21971499;
nntp1.Send("BODY " + Article.ToString() + "\r\n");
// this line reads stream till line with period only
s = nntp1.Receive(".\r\n");
Stream inMemStream, outMemStream;
inMemStream= new MemoryStream(Encoding.UTF8.GetBytes(s));
outMemStream= new MemoryStream();
inMemStream.Seek(0, 0);
yenc.DecodeFromRawStream(inMemStream, outMemStream);
outMemStream.Seek(0, 0);

StreamReader sr = new StreamReader(outMemStream, Encoding.UTF8);
string ArticleAttachment = sr.ReadToEnd();
__________________________________________________ ____________________

The problem is that the decoded string has only the upper case letters
right but the lower case letters are spaces.
If any one knows of any other components out there that can decode
yEnc please let me know.

Thanks
Marv

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Freddie | last post by:
Hi, I posted a while ago for some help with my word finder program, which is now quite a lot faster than I could manage. Thanks to all who helped :) This time, I've written a basic batch...
5
by: Marvin Grill | last post by:
Hi, I'm working on a type of NewsHound program and am stuck on how to decode the yEnc encoded articles (body). I tried using Joe Feser's yEnc class but can't seem to get it to work properly Not...
2
by: Phillip Hamlyn | last post by:
I'm trying to get a Yenc Decoding algorithm working but keep getting the same problem. I'm using data from the yenc test newsgroup and have tried the same thing with most of the example source code...
6
by: Scirious | last post by:
People, many of you may not know what yEnc is. To simplify, it is a methode to encode binary files very used in Usenet because it creates an overhead of only 2% when compare to 33%-40% of overhead...
6
by: Extremest | last post by:
Does anyone know how to decode a yenc encoded file? I have created a decoder that seems to work great for text. Now i am trying to create another one for images and I can't get it to work. I...
2
by: John Savage | last post by:
I save posts from a midi music newsgroup, some are encoded with yenc encoding. This gave me an opportunity to try out the decoders in Python. The UU decoder works okay, but my YENC effort gives...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.