Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6530203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:43:38+00:00 2026-05-25T09:43:38+00:00

Please help me with my problem in posting a JSON decoded emoji character. I

  • 0

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:

$postData = file_get_contents("php://input") to get the data.

then I use

$post = json_decode($postData,true);

to decode the data and have a assoc array and insert the data in database.

here is a code snippet when I insert my data into database.

$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'=>mysql_real_escape_string($post['from_id']),
                'user_id_to'=>mysql_real_escape_string($post['to_id']),
                'subject'=>mysql_real_escape_string($post['subject']),
                'message'=>mysql_real_escape_string($post['body']));

                $messages_obj->insert($data);

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.

I tried to use dummy data (line 2 in code snippet)

//$postData = '{"body":"characters here ","subject":"subject here","username":"janus","from_id":"185","to_id":"62"}';

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”))

This is how I encode and post my data in client.

    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];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:43:38+00:00Added an answer on May 25, 2026 at 9:43 am

    Once the data is sent to your php script you need to convert it to a multibyte string:

    $content = mb_convert_encoding($content, 'UTF-8');
    

    You can use this function:

    function cb($content){
    
      if(!mb_check_encoding($content, 'UTF-8')
       OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {
    
        $content = mb_convert_encoding($content, 'UTF-8');
    
      }
      return $content;
    }
    

    Edit: The data was probably of type application/x-www-form-urlencoded for us and that function converted it correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I have a synchronization problem...It may be too basic..Please help.. I have
I have a long string, ex: Please help me to solve this problem. This
Please help this would be my last problem in dealing with access database with
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
I am new in CSS so please help me in this problem. I hope
Still having issues with this problem. Please help if you can. So I am
Could someone please help solve this problem?
I have a problem posting the data from silverlight to the aspx page which
please help me this problem. I want to split -action=1 to action and 1.
I wrote a simple java application, I have a problem please help me; I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.