如何从数字中打印原始UTF-8字符? [英] How do you print raw UTF-8 characters from their numbers?

查看:82
本文介绍了如何从数字中打印原始UTF-8字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我想从U+00FF的Unicode/UTF-8编号或c3 bf的十六进制打印一个ÿ(带小写字母的拉丁字母y). 如何在PHP中做到这一点?

Say I wanted to print a ÿ (latin small y with diaeresis) from its Unicode/UTF-8 number of U+00FF or hex of c3 bf. How can I do that in PHP?

原因是我需要能够创建某些UTF-8字符,以便在我的正则表达式和字符串函数中进行测试.但是,由于我的键盘上的键少于200个,所以我无法键入,而且由于很多次我只能停留在ASCII唯一的世界中,因此我需要能够仅基于基数来创建它们 ASCII安全的UTF-8字符代码.

The reason is that I need to be able to create certain UTF-8 Characters is for testing in my regex and string functions. However, since I have less than 200 keys on my keyboard I can't type them - and since many times I am stuck in an ASCII only world - I need to be able to create them bases solely off of their ASCII safe, UTF-8 character code.

注意:为了使它在浏览器中正确显示,我知道第一步是

header('Content-Type: text/html; charset=utf-8');

推荐答案

好,您拥有所需的一切.
十六进制值也可以在双引号字符串中识别

well you have everything you need.
Hex values being recognized in double-quoted strings as well

echo "\xc3\xbf";

这篇关于如何从数字中打印原始UTF-8字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆