PDA

View Full Version : CLI output as plain ascii?



nine11turbo
2008-11-29, 01:02
when using the Command Line Interface via port 9090, can I make the beast talk back in plain ascii...?
I always get answers with HTML substitution characters (like %3A instead of a : or %20 for all blank etc.) which is less helpful on a user-interface that is not used with a browser normally...

Any ideas how to turn off this behaviour?

Thank,
Klaus

radish
2008-11-29, 10:57
It's URL encoded, not HTML encoded - and no, there's no way I know to switch it off. That's because plain ASCII doesn't support all the characters which might be needed (file/song names with wacky characters, etc). Don't know what you're writing your UI in but I'm sure it has a library to do URLdecode.

nine11turbo
2008-11-29, 15:05
...sorry, right its url...

...and no there is nothing like this (I write a interface for a Crestron controller)... About 80% of my processor-cycles (and there aren't too many...) I'm wasting with things like:

While (Find ("\x253A", work, 1) > 0) // while there are %3A
{ Work = mid(work, 1, Find ("\x253A", work, 1) - 1) + ":" +
mid(work, Find("\x253A",work,1)+3,
len(work)-1-Find "\x253A",work,1));
}

This is to replace %3A with a simple : ... I'd neet to do this for ??? characters. In the end the whole interface tends to be unusable because of this...
And I can't see the sense of url-encoding it. When its UTF-8, then just output UTF-8...

Klaus

radish
2008-11-30, 17:27
I've seen other Crestron modules around for SC, so it must be possible. Typically when doing a URL decode you wouldn't have a block like that for each different character, you'd look for %, and take the next 2 chars as a character code, then replace all 3 with the appropriate symbol. As for why it was chosen, my guess is for ease of delimitation. It's done in URLs because ":", "/" etc have special meaning, and it's the same here. Space for example is often used as a delimiter so if you have a space in a value it needs to be escaped. I guess URL encoding was just seen as convenient as it's a pretty widely understood scheme.

peterw
2008-11-30, 18:02
I've seen other Crestron modules around for SC, so it must be possible. Typically when doing a URL decode you wouldn't have a block like that for each different character, you'd look for %, and take the next 2 chars as a character code, then replace all 3 with the appropriate symbol.

Right, but that'll get you a byte but, IIUC, not necessarily a character. I think the CLI response is not merely URL-encoded, but the encoded bytes are UTF-8. This lets SqueezeCenter support all characters & languages over a 7-bit clean protocol.

gharris999
2008-11-30, 20:33
when using the Command Line Interface via port 9090, can I make the beast talk back in plain ascii...?
I always get answers with HTML substitution characters (like %3A instead of a : or %20 for all blank etc.) which is less helpful on a user-interface that is not used with a browser normally...

Any ideas how to turn off this behaviour?

Thank,
Klaus
If you can query from a windows client, you can use my SCCLITool to get the data. It has a "-t" option which translates the % and UTF8 encoding.

The zip includes the full source which perhaps you could adapt to whatever operating system you are using.

andyg
2008-11-30, 20:58
URI-unescaping is simple and fast. It only takes one line of Perl to do it. I'm sure you can find a similarly easy way to do it in whatever language you're using.

$string =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

nine11turbo
2008-12-01, 06:33
URI-unescaping is simple and fast. It only takes one line of Perl to do it. I'm sure you can find a similarly easy way to do it in whatever language you're using.

$string =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

if there would be something like RegEx in Crestron world it would be easy ;)

Thanks for all input but I think the way to go is to "offload" the parsing to the server where SqueezeCenter is running... Any hints where to look how to get a Netgear ReadyNAS to execute Pearl (or semething else like Python)scripts through a Telnet interface? This way the scripts could get the info from Squeezecenter, do all character conversion etc and deliver formatted text as I need it...?

thanks for all help
Klaus