0

I want to implement a class to read vorbis comments. I know that a field will start with a field name, followed by an equal sign and the value. But how does it end? Documentation makes me think that a semicolon will end the field but I checked an ogg file with a hex editor and I cannot see any.

This is how I think it should look like in a file :

TITLE=MY SUPER TITLE; 

The field name is title, followed by the equals sign and then the value is MY SUPER TITLE. And finally the semicolon to end the field.

But instead inside my file, the fields look like this :

TITLE=MY SUPER TITLE....

It's almost as above but there is no semicolon. The .'s are characters that cannot be displayed. I thought okay, it seems like the dots represent a value that will say "this is the end of the field!!" but they are almost always different. I noticed that there are always exactly 4 dots. The first dot has always a different value. The other free have usually a value of 0. But not always...

My question now, how does a field end? How do I read this comment?

Also, yeah I know that there are libraries and that I should use them instead of reinventing the wheel over and over again. I will use libraries later but first I want to know how to do it myself. Educational purpose only.

Davlog
  • 1,946
  • 6
  • 29
  • 55

1 Answers1

1

Each field is preceded by a little-endian 32-bit integer that indicates the number of bytes to read. You then convert the bytes to a string via UTF8.

See NVorbis' implementation (LoadComments(...)) for details.

ioctlLR
  • 1,149
  • 5
  • 12