开发者

how to decode string like this c'è [closed]

开发者 https://www.devze.com 2023-02-11 07:15 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I want to decode a string like c'è in utf8.

When encoding or / and decoding from one to another character-set is m开发者_如何学Goade, typical strings appear that show that something went wrong. Is it possible for the posted string to reconstruct the origin utf-8 string?


If you mean to change 'strange' characters like ä Ü into their equivalents a U, then this might help:

PHP Normalizer class


It is hard to say what you mean with “decoding” the string. A string in UTF-8 is just a valid string as it stands. You can convert it to another encoding, but you do not state which one you want to use. So, to convert a string from one encoding (e.g. UTF-8) to another (e.g. iso-8859-2), you can use e.g. the iconv() function, e.g.:

iconv("UTF-8", "ISO-8859-2", $text)

But be aware that there are many characters in Unicode (and UTF-8) which cannot be represented in a particular single-byte character set; check the PHP documentation for your options in such cases. (You might be able to just use the string in UTF-8, which is probably the best encoding available, anyway.)


If I do:

$string="c'è";
echo mb_detect_encoding($string);

I'd get:

UTF-8
0

精彩评论

暂无评论...
验证码 换一张
取 消