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 7767651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:43:46+00:00 2026-06-01T15:43:46+00:00

EDIT 2: I’d like to convert English words to unicode numbers using php5 and

  • 0

EDIT 2: I’d like to convert English words to unicode numbers using php5 and then produced as \u* * * * where * * * * is the unicode number.

In my original question, I had mistakenly thought that \u was a standard for encoding unicode when in fact it is just being escaped in JavaScript ( Thankyou Jukka K. Korpela for pointing this out). Even though I wanted to do the conversion in PHP the converted unicode was to be used in JavaScript.

I tried the below options, but had no luck. deceze’s answer did the trick though, thank you very much!

THINGS I TRIED

I’ve read that I can use iconv to do this, but I’ve had no luck and can’t find any examples on how.

I’ve also tried Scott Reynen’s code here How to get code point number for a given character in a utf-8 string? but I can’t seem to get it to work. When I tried it I included the script in a file along with

$str='test';
echo utf8_to_unicode($str);

It just echoed out test.

I’ve also read that I can use

echo json_encode("test");

but again I only get test printed to the screen.

Any help would be much appreciated.

EDIT1: Actually I think they are called code units not code points.

  • 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-06-01T15:43:48+00:00Added an answer on June 1, 2026 at 3:43 pm

    json_encode pretty much does it for you, but only for non-ASCII characters. So all you need to do is to convert ASCII characters by hand. Here’s a function that does that on a character-by-character basis:

    function utf8ToUnicodeCodePoints($str) {
        if (!mb_check_encoding($str, 'UTF-8')) {
            trigger_error('$str is not encoded in UTF-8, I cannot work like this');
            return false;
        }
        return preg_replace_callback('/./u', function ($m) {
            $ord = ord($m[0]);
            if ($ord <= 127) {
                return sprintf('\u%04x', $ord);
            } else {
                return trim(json_encode($m[0]), '"');
            }
        }, $str);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This question was exceptionally dumb and made me look like a script kiddie,
EDIT: Duplicate of Should Entity Framework Context be Put into Using Statement? I've been
EDIT: There's now a doc page on this so this question is irrelevant, also
Edit: I would like to model a 1 to 0:1 relationship between User and
Edit: The below question was answered by this . I have a new updated
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT : I've gotten the famous question badge with this question, so I figured
EDIT: I have reworded the title question slightly, and adjusted the text to respond
Edit: From another question I provided an answer that has links to a lot

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.