title: How do you add an attribute to an Unicode string in Swift?
body: <p>How do you add attribute to a UNICODE string in Swift? </p>
  
  <p>NSMakeRange seems to expect String in bytes for a variable byte length UNICODE string. </p>
  
  <p>Any way to solve this? Thanks in advance.</p>
  
  <pre><code>var s:NSMutableAttributedString = NSMutableAttributedString(string: "வாங்க வாங்க வணக்கமுங்க")
  s.string[0...2]
  s.addAttribute(NSForegroundColorAttributeName, value:UIColor(red:0.0, green:1.0, blue:0.0, alpha:1.0), range:NSMakeRange(0,3))
  </code></pre>
  
  <p>UPDATED EXAMPLE:</p>
  
  <pre><code>let text = "வாங்க வாங்க வணக்கமுங்க"
  var startOfWord = advance(text.startIndex, 4)
  var endOfWord = advance(startOfWord, 3)
  var highlightRange = startOfWord..&lt;endOfWord
  text[startOfWord..&lt;endOfWord]
  
  let attrText = NSMutableAttributedString(string:text)
  attrText.addAttribute(NSForegroundColorAttributeName, value:UIColor(red:0.0, green:1.0, blue:0.0, alpha:1.0), range:highlightRange)
  </code></pre>
  
  <p>How do construct NSRange from swift Range?</p>