dongxi5494 2014-10-17 12:35
浏览 69

PHP获取一个字符的ASCII码

How can I get the ASCII code of a character in PHP ??

http://www.backbone.se/urlencodingUTF8.htm

When I try:

$h = dechex(ord('ñ'));

echo $h;

I'm getting C3 when I should be getting f1

I want for example:

for 'ñ' -> %f1
for 'º' -> %ba

How can I get that?

Thanks in advance!!

  • 写回答

1条回答 默认 最新

  • duangu8264 2014-10-17 12:51
    关注

    As they told you in the comments, ñ is not standard ASCII. It is present on the extended ASCII table, but your source file may be saved in UTF-8 and thus ñ is stored with different bytes. You could try setting your editor to save documents in a different charset.

    However, what you're doing is really dangerous. Since as you see encoding can change, it's always a bad idea to write in source files characters that are not part of standard ASCII.

    Why do you need to do that operation? Is there another way? Can't you use UTF-8?

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决