title: How do I detect "ÿ" in a string in TCL?
body: <p>I am querying an old Tektronix 11801B sampling oscilloscope. When I query anything it always returns my result and then an endless string of either "ÿ" on one device or "ÿ.." on another device (both the same model). So, I decided I will read everything before I hit a "ÿ" when querying.</p>
  
  <p>Here are two ways that I have tried:</p>
  
  <pre><code># Issue command
  puts ${ChannelId} ${Command}
  
  # Set loop variables
  set Result [list]
  set Byte [read ${ChannelId} 1]
  set BadByte ÿ
  
  # Loop until BadByte is found
  while {![string equal -nocase ${Byte} ${BadByte}]} {
  
      # Append good bytes to a list
      lappend Result ${Byte}
  
      # Read next byte
      set Byte ::visa::read ${ChannelId} 1]
  }
  
  # Join and return result list
  return [join ${Result}]
  </code></pre>
  
  <p>And:</p>
  
  <pre><code># Set loop variable
  set Result [list]
  
  # Read channel 1 byte at a time until ÿ is found
  while {![string equal -nocase [set Character [read ${ChannelId} 1]] "ÿ"]} {
  
      # Append non ÿ characters to a list
      lappend Result ${Character}
  }
  
  # Join the result and return it
  return [join ${Result}]
  </code></pre>
  
  <p>In both cases, my loop just always returns true and becomes infinite. However, if I run the commands line by line in wish everything works properly.</p>