> The code for the perl binding has the following test: > > STRLEN len; > char *ptr = SvPV(value, len); > qpid::types::Variant v = qpid::types::Variant(std::string(ptr,len)); > if (SvUTF8(value)) { > v.setEncoding("utf8"); > } > > I presume this is supposed to test whether the value passed in is UTF8 > (this is before we have encoded it into the AMQP wire format). > > So, my question is whether you are saying that the test above (i.e. the > if statement) does not in fact work for some reason as a way to > determine whether to encode as str or bin?
Perl can store a scalar internally as binary or utf8, and SvUTF8 just tells you which mode is being used. If you give perl a string containing unicode characters, it'll encode it as utf8 internally so SvUTF8 is true and you know it's a textual string. However give it any non-unicode stream of bytes (inc. 7 bit ASCII) and it'll just store it as binary, AFAIK there is no way to tell a textual string from a binary string. I guess you could check all the bytes to ensure high bit is not set, if so you can safely say its a textual string, however doesn't seem like an optimum solution to me. Jimmy --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org