Bug 13758 - Wishlist: as.raw [or similar] support for tcl strings
Summary: Wishlist: as.raw [or similar] support for tcl strings
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: old
Hardware: All Linux
: P5 normal
Assignee: Jitterbug compatibility account
Depends on:
Reported: 2009-06-16 02:39 UTC by Jitterbug compatibility account
Modified: 2009-06-16 02:39 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2009-06-16 02:39:36 UTC
From: whorfin@pixar.com
Full_Name: Rick Sayre
Version: 2.9.0
OS: windows, os x, linux
Submission from: (NULL) (

if a tcl "string" contains binary data, there is a problem getting this data
to R, since there appears to be no way to get "raw" data without NULL
interpretation.  Here is a simple example.  The data should be
Here are 1<one NULL>Here is 2<two NULLs>And finally three<three NULLS>
> tq <- .Tcl("set tcls [binary format H*
#tclvalue stops returning data after the first NULL
> tclvalue("tcls")
[1] "Here are 1"
#interestingly, as.character gets more, but gets confused
> as.character(tq)
[1] "Here"    "are"     "1"       "is"      "2"       "finally" "three"
> # we confirm that the tcl representation does indeed have the NULLs:
> .Tcl("binary scan $tcls H* tmps")
<Tcl> 1
> tclvalue("tmps")
[1] "48657265206172652031004865726520697320320000416e642066696e616c6c79207468726565000000"

I would naively suggest something like tclrawvalue() and/or as.raw() utilizing

A good discussion of the basics of this issue for general tcl embedding can be
found here:

For those who might be wondering "what the heck are you doing trying to pass
binary data from tcl?", the answer is that non-blocking I/O does not work on
and timeouts, modes, and line control for RS232 ports aren't supported at all on
Using tcl provides a nice portable way to do this in R, but currently requires
converting everything to ascii encodings since the binary data fails to make it


Comment 1 Jitterbug compatibility account 2009-08-17 12:13:00 UTC
 Added for 2.10.0
Comment 2 Jitterbug compatibility account 2009-08-17 12:13:07 UTC
Audit (from Jitterbug):
Wed Jun 17 16:14:40 2009	ripley	moved from incoming to Add-ons
Mon Aug 17 07:13:06 2009	ripley	changed notes
Mon Aug 17 07:13:07 2009	ripley	moved from Add-ons to wishlst-fulfilled