escaped backslash in string
Hi all. I'm working on a project that requires me to send a backslash character via OSC. This construct is typical of C family languages: "\\hello" -------> prints: \hello but ChucK doesn't seem to let me escape a backslash. Instead I get [unrecognized escape sequence: '\h']. Same when I try to use octal: "\134hello" Setting aside the crazy fact that I have to send a backslash over OSC (it's for Guido music notation in InScore), does anyone know how to get a backslash in a ChucK string? Thanks, Joel
OK, I solved it. This fails: "\\hello" => xmit.addString; but this works: "\\hello" => string foo; foo => xmit.addString; I guess the addString method doesn't have fully recognize escape characters? Joel On 03/08/2013 03:44 PM, Joel Matthys wrote:
Hi all. I'm working on a project that requires me to send a backslash character via OSC.
This construct is typical of C family languages:
"\\hello" -------> prints: \hello
but ChucK doesn't seem to let me escape a backslash. Instead I get [unrecognized escape sequence: '\h'].
Same when I try to use octal: "\134hello"
Setting aside the crazy fact that I have to send a backslash over OSC (it's for Guido music notation in InScore), does anyone know how to get a backslash in a ChucK string?
Thanks, Joel
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On Fri, Mar 08, 2013 at 03:56:14PM -0500, Joel Matthys wrote:
OK, I solved it. This fails:
"\\hello" => xmit.addString;
but this works:
"\\hello" => string foo; foo => xmit.addString;
I guess the addString method doesn't have fully recognize escape characters?
Does not look like a addString issue to me as the two statements *should* be equivalent aside from the first string being anonymous. addString should not be aware of the difference, depending on the rest of the code the difference is only relevant to us and the garbage collector. I have a gut feeling this would fix it; "\\hello" @ new string => mit.addString; Something is going wrong initiating strings again; '"Hello"' -while anonymous- should be a string as much as '2' is a integer. Based on your example I'd say that escape characters get parsed when they enter the namespace instead of when a string gets created as would be proper. Strictly speaking that doesn't mean my gut-feeling solution should fix it as there the string stays anonymous too but often some extra assignment works. I think :-) Kas.
participants (2)
-
Joel Matthys
-
Kassen