Index: /trunk/src/core/RpEncode.cc
===================================================================
--- /trunk/src/core/RpEncode.cc	(revision 724)
+++ /trunk/src/core/RpEncode.cc	(revision 725)
@@ -33,19 +33,17 @@
 isbinary(const char* buf, int size)
 {
-    int index = 0;
-
-    if (size == -1) {
+    if (size < 0) {
         size = strlen(buf);
     }
 
-    for (index = 0; index < size; index++) {
-        if (((buf[index] >= '\000') && (buf[index] <= '\010')) ||
-            ((buf[index] >= '\013') && (buf[index] <= '\014')) ||
-            ((buf[index] >= '\016') && (buf[index] <= '\037')) ||
-            ((buf[index] >= '\177') && (buf[index] <= '\377')) ) {
+    for (int index = 0; index < size; index++) {
+        int c = *buf++;
+        if (((c >= '\000') && (c <= '\010')) ||
+            ((c >= '\013') && (c <= '\014')) ||
+            ((c >= '\016') && (c <= '\037')) ||
+            ((c >= '\177') && (c <= '\377')) ) {
             // data is binary
             return index+1;
         }
-
     }
     return 0;
Index: /trunk/src/tcl/src/RpEncodeTclInterface.cc
===================================================================
--- /trunk/src/tcl/src/RpEncodeTclInterface.cc	(revision 724)
+++ /trunk/src/tcl/src/RpEncodeTclInterface.cc	(revision 725)
@@ -78,20 +78,8 @@
 
 int
-RpTclEncodingIs     (   ClientData cdata,
-                        Tcl_Interp *interp,
-                        int objc,
-                        Tcl_Obj *const objv[]  )
+RpTclEncodingIs (ClientData cdata, Tcl_Interp *interp,
+    int objc, Tcl_Obj *const objv[])
 {
-    const char* type     = NULL; // type of data being checked
-    const char* buf      = NULL; // buffer to be checked
-    const char* cmdName  = NULL;
-
-    int typeLen          = 0;
-    int bufLen           = 0; // length of user provided buffer
-    int nextarg          = 0;  // next argument
-
     Tcl_ResetResult(interp);
-
-    cmdName = Tcl_GetString(objv[nextarg++]);
 
     // parse through command line options
@@ -99,31 +87,27 @@
         Tcl_AppendResult(interp,
             "wrong # args: should be \"",
-            cmdName," binary <string>\"",
+            Tcl_GetString(objv[0])," binary <string>\"",
             (char*)NULL);
         return TCL_ERROR;
     }
 
-    type = Tcl_GetStringFromObj(objv[nextarg++],&typeLen);
-    buf = Tcl_GetStringFromObj(objv[nextarg++],&bufLen);
-
-    if (strncmp(type,"binary",typeLen) == 0) {
+    const char *type = Tcl_GetString(objv[1]);
+
+    int bufLen;
+    const char *buf = (const char*) Tcl_GetByteArrayFromObj(objv[2],&bufLen);
+
+    if (strcmp(type,"binary") == 0) {
         if (Rappture::encoding::isbinary(buf,bufLen) != 0) {
             // non-ascii character found, return yes
-            Tcl_AppendResult(interp, "yes",(char*)NULL);
-            return TCL_OK;
+            Tcl_AppendResult(interp, "yes", (char*)NULL);
+        } else {
+            Tcl_AppendResult(interp, "no",(char*)NULL);
         }
-    }
-    else {
-        Tcl_AppendResult(interp, "bad option \"", type,
-                "\": should be binary",
-                (char*)NULL);
-        return TCL_ERROR;
-
-    }
-
-    // default return
-    // no binary characters found, return no
-    Tcl_AppendResult(interp, "no",(char*)NULL);
-    return TCL_OK;
+        return TCL_OK;
+    }
+    Tcl_AppendResult(interp, "bad option \"", type,
+            "\": should be binary",
+            (char*)NULL);
+    return TCL_ERROR;
 }
 
Index: /trunk/src/tcl/tests/encode.test
===================================================================
--- /trunk/src/tcl/tests/encode.test	(revision 724)
+++ /trunk/src/tcl/tests/encode.test	(revision 725)
@@ -52,4 +52,8 @@
     list [catch {Rappture::encoding::is binary binary "hi"} msg] $msg
 } {1 {wrong # args: should be "Rappture::encoding::is binary <string>"}}
+
+test is-1.2.2 {Rappture::encoding::is, with an embedded null} {
+    list [catch {Rappture::encoding::is binary "x\000x"} msg] $msg
+} {0 yes}
 
 #----------------------------------------------------------
