UTF8 question

Discussion in 'C-Bus Wiser 2 Controller' started by MHeaton, Jul 26, 2015.

  1. MHeaton

    MHeaton

    Joined:
    Apr 22, 2008
    Messages:
    107
    Likes Received:
    2
    Location:
    London
    Hi there,
    I am sending my Wiser a MEDIATRANSPORT TRACK_NAME command via a CGate Connection and multibyte UTF-8 characters seem to kill it:

    Take the song
    The Anchor Song - Bj?rk
    which corresponds to these Unicode wide characters:
    54 00 68 00 65 00 20 00 41 00 6e 00 63 00 68 00 6f 00 72 00 20 00 53 00 6f 00 6e 00 67 00 20 00 2d 00 20 00 42 00 6a 00 f6 00 72 00 6b 00 00 00

    (The o after the j has an umlaut on it.

    In UTF-8 this:
    The Anchor Song - Björk

    or expressed in bytes
    54 68 65 20 41 6e 63 68 6f 72 20 53 6f 6e 67 20 2d 20 42 6a c3 b6 72 6b 00

    I also see the message in the Toolkit log expressed as:
    26/07/2015 16:50:24.832,192,Media Transport Control,1,Master Bedroom,21,PCINT,"Track Name: "The Anchor", Next, (packet 1 of 3)"
    26/07/2015 16:50:24.932,192,Media Transport Control,1,Master Bedroom,21,PCINT,"Track Name: "Song - Bj??", Next, (packet 2 of 3)"
    26/07/2015 16:50:24.992,192,Media Transport Control,1,Master Bedroom,21,PCINT,"Track Name: "rk", Next, (packet 3 of 3)"

    implying it has not understood the UTF-8-either.

    However, the bigger problem is that this string seems to send the Wiser into an infinite loop of some sort as once it receives it it stops accepting requests and needs the plug to be pulled....

    Mark
     
    Last edited by a moderator: Jul 26, 2015
    MHeaton, Jul 26, 2015
    #1
  2. MHeaton

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,400
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    Media transport does split things up into pieces to send them.

    As UTF-8 encoding is used, there is no need to interpret or specially handle the UTF-8 string (its just a stream of bytes).

    What does need to happen is the Wiser should paste the pieces back together before doing any further work on the string (eg turning it from UTF-8 into some other encoding).

    It would seem this is not being done.

    It may help the developers if you can move the Umlaut to some other spot that's not in the middle of a media transport packet break.... just from curiosity to see what happens.
     
    ashleigh, Jul 28, 2015
    #2
  3. MHeaton

    MHeaton

    Joined:
    Apr 22, 2008
    Messages:
    107
    Likes Received:
    2
    Location:
    London
    Ashleigh,
    Thanks - I have swapped the text round so it becomes
    Bj?rk - The Anchor Song

    so that the Bjork is firmly inside the 11 byte message and the problem occurs for that too. :(

    One other comment - my code is splitting the string on the 11 byte marks (per the documentation) into the packets not C-GATE.

    Thanks

    Mark
     
    Last edited by a moderator: Jul 28, 2015
    MHeaton, Jul 28, 2015
    #3
  4. MHeaton

    daniel C-Busser Moderator

    Joined:
    Jul 26, 2004
    Messages:
    770
    Likes Received:
    21
    Location:
    Adelaide
    Hi MHeaton, what are the exact C-Gate commands you are sending?
     
    daniel, Jul 29, 2015
    #4
  5. MHeaton

    MHeaton

    Joined:
    Apr 22, 2008
    Messages:
    107
    Likes Received:
    2
    Location:
    London
    Daniel,
    Hi there. You can call me Mark :)

    I am sending the following three commands:
    (in each case expressed as a string or as a byte sequence)
    Regards
    Mark

    MEDIATRANSPORT TRACK_NAME //HYDEPARK/254/$C0 1 1 2 0 The Anchor

    4d 45 44 49 41 54 52 41 4e 53 50 4f 52 54 20 54 52 41 43 4b 5f 4e 41 4d 45 20 2f 2f 48 59 44 45 50 41 52 4b 2f 32 35 34 2f 24 43 30 20 31 20 31 20 32 20 30 20 54 68 65 20 41 6e 63 68 6f 72 20 0d 0a

    MEDIATRANSPORT TRACK_NAME //HYDEPARK/254/$C0 1 1 2 1 Song - Bjö

    4d 45 44 49 41 54 52 41 4e 53 50 4f 52 54 20 54 52 41 43 4b 5f 4e 41 4d 45 20 2f 2f 48 59 44 45 50 41 52 4b 2f 32 35 34 2f 24 43 30 20 31 20 31 20 32 20 31 20 53 6f 6e 67 20 2d 20 42 6a c3 b6 0d 0a

    MEDIATRANSPORT TRACK_NAME //HYDEPARK/254/$C0 1 1 2 2 rk

    4d 45 44 49 41 54 52 41 4e 53 50 4f 52 54 20 54 52 41 43 4b 5f 4e 41 4d 45 20 2f 2f 48 59 44 45 50 41 52 4b 2f 32 35 34 2f 24 43 30 20 31 20 31 20 32 20 32 20 72 6b 0d 0a
     
    MHeaton, Jul 29, 2015
    #5
  6. MHeaton

    MHeaton

    Joined:
    Apr 22, 2008
    Messages:
    107
    Likes Received:
    2
    Location:
    London
    Also, while we are playing around in here if the last character in a fragment is a space it doesn't get propagated! - would be better to double quote the string
     
    MHeaton, Jul 31, 2015
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.