title: Julia: comparing strings with special characters
body: <p>I need to read a text file which contains <code>csv</code> data with headers separating individual blocks of data. The headers always start with the dollar sign <code>$</code>. So my text file looks like:</p>
  
  <pre><code>$Header1
  2
  1,2,3,4
  2,4,5,8
  $Header2
  2
  1,1,0,19,9,8
  2,1,0,18,8,7
  </code></pre>
  
  <p>What I want to do is if the program reaches to <code>$Header2</code>, I want to read all the next lines following it till it reaches, say, <code>$Header3</code> or end of the file. I think I can use `cmp' in Julia for this. I tried with a small file that contains following text:</p>
  
  <pre><code># file julia.txt
  Julia
  $Julia
  </code></pre>
  
  <p>and my code reads:</p>
  
  <pre><code># test.jl
  fname = "julia.txt"
  # set some string values
  str1 ="Julia";
  str2 ="\$Julia";
  # print the strings and check the length
  println(length(str1),",",str1);
  println(length(str2),",",str2);
  # now read the text file to check if you are able to find the strings
  # str1 and str2 above
  println ("Reading file...");
  for ln in eachline(fname)
   println(length(ln),",",ln);
   if (cmp(str1,ln)==0)
    println("Julia match")
   end
   if (cmp(str2,ln)==0)
    println("\$Julia match")
   end
  end
  </code></pre>
  
  <p>what I get as output from the above code is:</p>
  
  <pre><code>5,Julia
  6,$Julia
  Reading file...
  6,Julia
  
  7,$Julia
  </code></pre>
  
  <p>I don't understand why I get character length of 6 for string <code>Julia</code> and 7 for the string <code>$Julia</code> when they are read from the file. I checked the text file by turning on white spaces and there are none. What am i doing wrong?</p>