From: Stephen D. <sd...@gm...> - 2005-06-10 16:51:59
|
Tcl_ObjType byteArrayType =3D Tcl_GetObjType("bytearray"); On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > The problem is, there is no Public API to check object for ByteArray > type. You have to include tclInt.h for this which is not public. >=20 > Stephen Deasey wrote: > > On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > > > >>I thought about ns_return -binary as well. first -binary flag is > >>optional so it will be compatible with the old API. Let me try this. > >> > >>Zoran Vasiljevic wrote: > >> > >>>Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: > >>> > >>> > >>>>* Tcl_GetByteArrayFromObj -- > >>>>* > >>>>* Attempt to get the array of bytes from the Tcl object. If the > >>>>* object is not already a ByteArray object, an attempt will be > >>>>* made to convert it to one. > >>>> > >>>>So, if i call ns_return from Tcl and pass data parameter, it will be > >>>>always type of String. ByteArrays are created from Tcl by binary > >>>>command only, other commands work with String types, so i need to > >>>>tell ns_return to treat data as bytearray. Tcl string > >>>>can contain binary data but it is still String and that check will > >>>>never work for binary data. > >>>> > >>> > >>>I'm afraid you are right. I also have my own (binary-aware) ns_return > >>>somewhere > >>>in my toolbox but never thought it would be of general interest. > >>> > >>>OTOH, the "ns_return -binary" would look nicer but I do not > >>>know if we'd be backwardly-compatible (guess not). > > > > > > > > The *only* thing a Tcl string can contain is valid UTF8. If you're > > putting something other than UTF8 in there, you've got big problems... > > > > Now, sending a UTF8 string directly to the client as a bytearray is > > effectively the same as sedinding it in the UTF8 encoding, i.e. the > > client will recieve exactly what was in memory for that string, > > because no transcoding to some other character set will be occur. > > There is API for setting the encoding on a per connection basis. > > > > The only way to pass a buffer of arbitrary (non-UTF8) bytes to a > > command is as a bytearray object. You can create these with the > > [binary] command, by opening a file with -translation binary, or from > > some extension such as the image example I gave above. That being the > > case, you should be able to check the type of the object given to > > ns_return, and act accordingly > > > > It's for these reasons that ns_returnbinary and ns_return -binary are > > fundamentaly broken. > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you s= hotput > > a projector? How fast can you ride your desk chair down the office luge= track? > > If you want to score the big prize, get to know the little guy. > > Play to win an NEC 61" plasma display: http://www.necitguy.com/?r > > _______________________________________________ > > naviserver-devel mailing list > > nav...@li... > > https://lists.sourceforge.net/lists/listinfo/naviserver-devel >=20 > -- > Vlad Seryakov > 571 262-8608 office > vl...@cr... > http://www.crystalballinc.com/vlad/ >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you sho= tput > a projector? How fast can you ride your desk chair down the office luge t= rack? > If you want to score the big prize, get to know the little guy. > Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |