ProximityMessage Data field encoding with \0 between characters RRS feed

  • Question

  • Hello,

    I have an app that has the following function:

    void MessageReceived(ProximityDevice device, ProximityMessage message)


             DataReader reader = DataReader.FromBuffer(message.Data);

             string str = reader.ReadString(reader.UnconsumedBufferLength);


    When I inspected the str in my debugger, I see '\0' between each of my character in my string that I passed as Uri over from my Android NFC tap. Also see two extra '\0' at the end of my string.

    I tried adding the below before my reader.ReadString(reader.UnconsumedBufferLength / 2)

          reader.UnicodeEncoding = UnicodedEncoding.Utf16LE   

    I got the correct string back for Uri but still have an extra '0' at the end of my string

    Any clue?


    Tuesday, August 7, 2012 10:12 PM


  • What did you pass as the messageType when calling SubscribeForMessage? The messageType should identify the message content's format/protocol. For instance, you mentioned that you sent a Uri, so you may have subscribed to "WindowsUri", which our documentation specifies will be UTF-16LE: http://msdn.microsoft.com/en-us/library/windows/apps/hh701129.aspx.

    It's also not clear what you mean when you say there is an extra '0' at the end of your string? Do you mean the decoded string looks like this: http://bing.com0? If so, I would start by confirming that the device you are sending the content from is sending the correct data.

    -Mike [MSFT]

    Wednesday, August 8, 2012 5:59 PM