let asciiz s =
  let rec findfirstnul str idx len =
    if ((idx==len) || 
        (str.[idx]==(char_of_int 0))) then idx
    else
      findfirstnul str (idx+1) len
  in
  let nulterm = findfirstnul s 0 (String.length s) in
    String.sub s 0 nulterm