Best of both encoding worlds?

  • Thread starter Thread starter polarz
  • Start date Start date
P

polarz

I wrote a front end to a command line mp4 music tagger that reads
my playlist files and gets info such as artist, title, album, etc,
etc. I use the info to catalog, tag, sort, etc, my files. I've run
into a small encoding problem. I started using a fopen like so.

fopen = new StreamReader(myPlaylist);

Everything worked well until I ran into groups like Mötley Crüe
with strange chars in the title. The default encoding above failed
to recognise the odd chars in "Mötley Crüe". I then went to

fopen = new StreamReader(myPlaylist,Encoding.UTF7);

This correctly picked up the odd chars in Mötley Crüe, and
everything else I thought until I noticed a file with a '+' in
the file name wasn't getting picked up now. My question is for
lack of a better one, is there anyway to use both encodings at
the same time? I did try every other encoding besides UTF7 and
also tried:

fopen = new StreamReader(myPlaylist,Encoding.UTF7,true);

I'm out of ideas here :/ Any advice is much appreciated.

Thank you
 
Well, you should find out what encoding your playlist file uses, and use the
same.

-mike
MVP
 
polarz said:
I wrote a front end to a command line mp4 music tagger that reads
my playlist files and gets info such as artist, title, album, etc,
etc. I use the info to catalog, tag, sort, etc, my files. I've run
into a small encoding problem. I started using a fopen like so.

fopen = new StreamReader(myPlaylist);

Everything worked well until I ran into groups like Mötley Crüe
with strange chars in the title. The default encoding above failed
to recognise the odd chars in "Mötley Crüe". I then went to

fopen = new StreamReader(myPlaylist,Encoding.UTF7);

This correctly picked up the odd chars in Mötley Crüe, and
everything else I thought until I noticed a file with a '+' in
the file name wasn't getting picked up now. My question is for
lack of a better one, is there anyway to use both encodings at
the same time? I did try every other encoding besides UTF7 and
also tried:

fopen = new StreamReader(myPlaylist,Encoding.UTF7,true);

I'm out of ideas here :/ Any advice is much appreciated.

It sounds like UTF7 just isn't the encoding used. It's very unlikely to
be the one used - I've very rarely actually come across applications
which use it. What's generating the playlist file, and do you have any
documentation about the format?
 
This may sound obvious (seeing as you said you tried every encoding
available), but have you tried Encoding.Default? Default encoding is ANSI
which includes the 7-Bit ASCII characters and then some.

Hope this helps,
Jacob
 
/me thwaps himself. Using Encoding.Default worked, I assumed by
leaving the fopen with no specific encoding it would use the
default encoding. Sorry for the dumb question and thanks for the
replys.
 
Thanks for the reply Mike. I had already tried that and got
System.Text.CodePageEncoding which can't be accessed due to
its protection level. I found an answer to my question in one
of the other responses. Thanks again.
 
No prob.

Jacob



polarz said:
/me thwaps himself. Using Encoding.Default worked, I assumed by
leaving the fopen with no specific encoding it would use the
default encoding. Sorry for the dumb question and thanks for the
replys.
 
Back
Top