Re: problem with asc function
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 31 Dec 2005 17:50:15 -0000
guoqi zheng <no@xxxxxxxxx> wrote:
> >>That is converting the character to a byte using the default encoding of
> the current thread - is that
> definitely what you want to do?
>
> I think I know why I have error but you don't have. Because we have
> different codepage/encoding.
Almost certainly.
> I am trying to decode yEnc encoded binary post on newsgroup, those bytes
> will be written to a output stream directly. I am not sure what kind of
> encoding they used originally to decode those binary, what I know is that I
> need to remove \r\n, convert it back to byte and write it to a binary file.
Without knowing the encoding, you can't recognise the "\r\n".
> Actually, it was always my question, what kind of encoding I should use to
> convert bytes I received from NNTP to string? I used ISO-8859-1 for now.
Well, it sounds to me like you don't really need to convert the bytes
at all. If you assume that the "\r\n" are encoded as bytes 13 and 10
respectively, you should be able to do it all without ever treating it
as text data.
If you *have* to treat it as character data, using 8859-1 is probably a
good bet. In theory I believe it doesn't contain characters for bytes
128-139, but in practice I believe the encoding treats them as Unicode
128-139.
Alternatively, just cast each character to a byte using CByte.
I've just had a look at the yEnc spec, and unfortunately it seems to
have been written by someone who doesn't appreciate the difference
between binary data and text data, and also doesn't understand that
ASCII doesn't have any values > 127...
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- Re: problem with asc function
- From: Jon Skeet [C# MVP]
- Re: problem with asc function
- From: guoqi zheng
- Re: problem with asc function
- Prev by Date: Re: Notepad.exe within Windows Service ?
- Next by Date: Re: I have 2 versions of .NET, which is being used
- Previous by thread: Re: problem with asc function
- Next by thread: Re: I have 2 versions of .NET, which is being used
- Index(es):
Relevant Pages
|