spaces in binary file not showing

Reply

Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

spaces in binary file not showing

 
0
  #1
Dec 9th, 2005
I am trying to open a mp3 to read the ID3 tag information, when the mp3 is opened in an ASCII editor I can see all the information I want, including spaces. But...
When I try running the following chunk of code on that same mp3, I get the same thing, except all the spaces are missing.

  1. for (int i=0; i<350; i++) {
  2. mp3 >> stream[i];
  3. cout << stream[i];
  4. }

I've tried opening the file as both ascii and binary, using the >>
operator and mp3.get(stream[i]) notation, but there is never a space. As a last resort I tried casting off all the characters to ints and looking at that, but the space isn't there.
Is there something I am doing wrong?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,152
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1437
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: spaces in binary file not showing

 
0
  #2
Dec 10th, 2005
its probably because what you see in the ascii editor are not spaces at all. Many editors, such as Notepad will display non-printable characters as spaces. What makes you think that file contains spaces? binary files contains all sorts of stuff that are meaningless to ascii edits. If you realy want to see what is in the file, and you are on MS-Windows os, you can use debug.exe that is in the MS-Windows installation directory -- that program has been distrubuted with every M$ operating system since MS-DOS 1.0 over 20 years ago. It has a split screen. On the left side is the hex values of every byte in the file. The right side contains the ascii values where non-printable bytes are displayed as a '.' (period).
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: spaces in binary file not showing

 
0
  #3
Dec 10th, 2005
the reason I say they are spaces is because they part of the file that I am looking at is the ID3 tag of an MP3. In the ID3 tag, you can store information about an mp3 such as the artist, album, title, etc....

When I open the file in winamp I can see the space between "The Beatles" under the artist field, and I see it in my ASCII editor.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,152
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1437
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: spaces in binary file not showing

 
0
  #4
Dec 10th, 2005
The >> operator strips the spaces. If you want to retain them use read() function.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC