title: How do I specify a unicode message body in a Twilio SMS request?
body: <p><a href="http://forum.twilio.com/twilio/topics/spanish_sms_inbound_outbound#reply_9497615" rel="nofollow">According to Twilio</a>, they now support unicode characters in their RESTful SMS interface. However, it's not clear to me how I can take advantage of this in Javascript (this is in Node). </p>
  
  <p>When I send SMS messages with Spanish translations (defaulting to UTF-8), the message will get chopped into three messages on the recipients phone. I'm guessing that the root cause is I need to send a unicode message body in the request. </p>
  
  <p>How can I convert a Javascript string into unicode? I've attempted a character-by-character translation...</p>
  
  <pre><code>function toUnicode(theString) {
    var unicodeString = '';
    for (var i=0; i &lt; theString.length; i++) {
      var theUnicode = theString.charCodeAt(i).toString(16).toUpperCase();
      while (theUnicode.length &lt; 4) {
        theUnicode = '0' + theUnicode;
      }
      theUnicode = '\\u' + theUnicode;
      unicodeString += theUnicode;
    }
    return unicodeString;
  }
  </code></pre>
  
  <p>... but that produces a message body that is interpreted as being longer then the 160 character limit.</p>