"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Convert a Unicode Code Point to Its Corresponding Character in PHP?

How to Convert a Unicode Code Point to Its Corresponding Character in PHP?

Posted on 2025-02-17
Browse:365

How to Convert a Unicode Code Point to Its Corresponding Character in PHP?

Unicode encoding point in PHP

In PHP, it is a common task to obtain characters corresponding to the specified Unicode encoding point. Unicode is a character encoding standard used to represent text across different platforms and languages.

Question: How to get the characters of U 010F? For example, how to get the characters corresponding to the U 010F Unicode encoding point? This encoding point corresponds to the Latin lowercase letter o with pointed notes, or “ó”.

Answer:

PHP provides several functions to handle Unicode encoding points:

hexdec()
    ] : Convert a hexadecimal string to a decimal integer.
  • mb_ord()
  • : Get the Unicode code point of the string (supported by multibyte string).
  • mb_chr()
  • : Convert Unicode code points to strings (multi-byte string support).
  • The following is an example code for getting U 010F characters:

var_dump(hexdec('010F')); var_dump(mb_ord('ó')); // 243 var_dump(mb_chr(243)); // ó

var_dump(hexdec('010F'));

var_dump(mb_ord('ó')); // 243
var_dump(mb_chr(243)); // ó
int(271) int(243) string(1) "ó"

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3