title: golang, £ char causing weird Â character
body: <p>I have a function that generates a random string from a string of valid characters. I'm occasionally getting weird results when it selects a £</p>
  <p>I've reproduced it to the following minimal example:</p>
  <pre><code>func foo() string {
      validChars := &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~@:!£$%^&amp;*&quot;
      var result strings.Builder
  
      for i := 0; i &lt; len(validChars); i++ {
  
          currChar := validChars[i]
          result.WriteString(string(currChar))
      }
      return result.String()
  }
  </code></pre>
  <p>I would expect this to return</p>
  <p><code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~@:!£$%^&amp;*</code></p>
  <p>But it doesn't, it produces</p>
  <pre><code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~@:!Â£$%^&amp;*
                                                                    ^
                                               where did you come from ?
  </code></pre>
  <p>if I take the £ sign out of the original validChars string, that weird A goes away.</p>
  <pre><code>func foo() string {
      validChars := &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~@:!$%^&amp;*&quot;
      var result strings.Builder
  
      for i := 0; i &lt; len(validChars); i++ {
  
          currChar := validChars[i]
          result.WriteString(string(currChar))
      }
      return result.String()
  }
  </code></pre>
  <p>This produces
  <code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~@:!$%^&amp;*</code></p>