PHP:将Unicode字符串转换为ANSI字符串 [英] PHP: Converting Unicode strings to ANSI strings

查看:141
本文介绍了PHP:将Unicode字符串转换为ANSI字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP是否有任何标准函数将Unicode字符串转换为普通的老式ANSI字符串(或PHP htmlentities理解的任何格式?)?

Does PHP have any standard function(s) to convert Unicode strings to plain, good old-fashioned ANSI strings (or whatever format PHP's htmlentities understands?

是否存在将UTF-8字符串转换为大多数流行的浏览器可以理解的HTML的函数?

Is there any function that converts UTF-8 strings to HTML that can be understood by the most popular browsers?

推荐答案

这不能正常工作.与Unicode存储在一起的字符比与ANSI存储的字符更多. 因此,如果您转换"为ANSI,则会失去很多特征.

This can't work properly. Stored with Unicode there are many more Characters than with ANSI. So if you "convert" to ANSI, you will loose lots of charackters.

http://php.net/manual/en/function.htmlentities.php

您可以将Unicode(UTF-8)字符集与htmlentities一起使用:

You can use Unicode (UTF-8) charset with htmlentities:

string htmlentities ( string $string [, int $flags = ENT_COMPAT [, string $charset [, bool $double_encode = true ]]] )

htmlentities($myString, ENT_COMPAT, "UTF-8");应该可以.

这篇关于PHP:将Unicode字符串转换为ANSI字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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