Null values in strings - encoding problem?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrData23
    New Member
    • Jun 2007
    • 2

    #1

    Null values in strings - encoding problem?

    Hi,

    I'm attempting to read some titles and other information from a file that holds information on audio files.

    The file follows this format -

    TIT2 Name_of_song TPE1 Name_of_album etc.

    The problem I am having is that each letter of the song title is followed by a null character, as you can see below:

    TIT2\0\0D\0a\0 n\0c\0i\0n\0g\0 \0Q\0u\0e\0e\0n \0\0\0\0\0\0\0\ 0\0

    Is there any way to read this in correctly, or do I just have to replace all nulls with String.Empty? I've tried all the different Encoding formats I can, but it seems that nothing works.

    Any help is much appreciated.

    Steven
  • cmorgan76
    New Member
    • Jun 2007
    • 11

    #2
    I've never had that problem before. Have you tried splitting the string?

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Is that not 16bit unicode? It looks kinda like it to me, but I don't have a lot of experiance with it.
      You have Dancing Queen so the first letter D as bytes would be like 0x00 0x44 (or 0x44 0x00 in reverse byte order)
      Which means that the D character is really 0x0044 or 0x4400 if 16bits specify each character.

      You could always try reading the file in as bytes and then only looking at every other byte. (Myabe use bitconverter to create a 16bit int then cast it as a char?)

      Comment

      • mrData23
        New Member
        • Jun 2007
        • 2

        #4
        Thanks for your suggestion. However, the file looks as though it has two encodings in it, possibly - if it was 16bit unicode, would the 'TIT2' at the start not read '\0T\0I\0T\02' ? Or have I got the wrong end of the stick?

        I am at the moment using substring to get the string between the two tags and then replace the '\0' with an empty string, which does seem to work. Maybe I'll stick with that unless anyone has any other ideas?

        Comment

        Working...