title: Emoji to JSON encoded, post to web server
body: <p>Please help me with my problem in posting a JSON decoded emoji character.
  I have a UITextView, this text view may have a emoji character. I am posting the data to a web server with the UITextView.text presented as JSON, the problem is when the text has a an emoji, I am not able to get the data. What I do is:</p>
  
  <pre><code>$postData = file_get_contents("php://input") to get the data.
  </code></pre>
  
  <p>then I use </p>
  
  <pre><code>$post = json_decode($postData,true);
  </code></pre>
  
  <p>to decode the data and have a assoc array and insert the data in database. </p>
  
  <p>here is a code snippet when I insert my data into database.</p>
  
  <pre><code>$postData = file_get_contents("php://input");
  //$postData = '{"body":"characters here ","subject":"subject here","username":"janus","from_id":"185","to_id":"62"}';
      $post = json_decode($postData,true);
          $data=array(
                  'user_id_from'=&gt;mysql_real_escape_string($post['from_id']),
                  'user_id_to'=&gt;mysql_real_escape_string($post['to_id']),
                  'subject'=&gt;mysql_real_escape_string($post['subject']),
                  'message'=&gt;mysql_real_escape_string($post['body']));
  
                  $messages_obj-&gt;insert($data);
  </code></pre>
  
  <p>Without an emoji character found, it works fine. no problem. the problem is when an emoji character found, the data in $post (decoded data) is null.</p>
  
  <p>I tried to use dummy data (line 2 in code snippet) </p>
  
  <pre><code>//$postData = '{"body":"characters here ","subject":"subject here","username":"janus","from_id":"185","to_id":"62"}';
  </code></pre>
  
  <p>and I succesfully inserted the emoji characters in database. I dont know why but It dont work the same when the data is from the device ($postData = file_get_contents("php://input"))</p>
  
  <p>This is how I encode and post my data in client.</p>
  
  <pre><code>    NSMutableDictionary *messageDetails = [[NSMutableDictionary alloc] init];
  [messageDetails setObject:[loginItems objectForKey:@"user_id"] forKey:@"from_id"];
  [messageDetails setObject:recipientID forKey:@"to_id"];
  [messageDetails setObject:@"subject here" forKey:@"subject"];
  [messageDetails setObject:newMessageField.text forKey:@"body"];
      [messageDetails setObject:[loginItems objectForKey:@"username"] forKey:@"username"];
  
  
  NSString *strPostData = [messageDetails JSONRepresentation];
  [messageDetails release];
  
  NSData *postData = [NSData dataWithBytes:[strPostData   UTF8String] length:[strPostData  length]];
  [urlRequest setHTTPMethod:@"POST"];
  [urlRequest setHTTPBody:postData];
  </code></pre>