title: Backslash in string changing output
body: <p>I am currently trying to implement a method that counts the number of characters and digits in a string. However if I use a string that contains the '\' character I am getting strange results. I am guessing it's because the backslash character is an escape character. </p>
  
  <p>Here is the method:</p>
  
  <pre><code>import Data.Char
  
  countLettersAndDigits :: String -&gt; Int
  countLettersAndDigits [] = 0
  countLettersAndDigits (x:xs) = if isDigit x == True || isLetter x == True 
                                 then 1 + countLettersAndDigits xs 
                                 else countLettersAndDigits xs 
  </code></pre>
  
  <p>Here is a set of inputs with their respective results:</p>
  
  <blockquote>
    <p>"1234fd" -> 6 (Doesn't contain '\')</p>
    
    <p>"1234f\d" -> lexical error in string/character literal at character
    'd'</p>
    
    <p>"1234\fd" -> 5</p>
    
    <p>"123\4fd" -> 5</p>
    
    <p>"12\34fd" -> 4</p>
    
    <p>"1\234fd" -> 4</p>
    
    <p>"\1234fd" -> 3</p>
  </blockquote>
  
  <p>I find it strange that, for example, "1234\fd" and "123\4fd" both give 5 as a result.</p>
  
  <p>Any help explaining why this maybe the case and also how to get around this problem? would be great!</p>
  
  <p>Cheers.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I forgot to mention that the string that I used above was just an example I was playing with. The actual string that is causing a problem is being generated by Quick Check. The string was "\178". So I require a way to be able to handle this case in my code when their is only one backslash and the string is being generated for me. Cheers.</p>