This question already has answers here:
Unicode character in PHP string
(8 answers)
Closed 2 years ago.
I'm trying to convert some characters with PHP before inserting to MySQL DB a JSON object with this kind of data:
\u00c9
that means: É
I tried this but it didn't work:
echo utf8_encode(print_r('\u00c9'));
I've read that it's in Unicode but i can't find the way to print it before inserting it. Any ideas?
Take a look at this answer. TL;DR:
echo json_decode('"\u00c9"');
Related
This question already has answers here:
Convert utf8-characters to iso-88591 and back in PHP
(10 answers)
Closed 6 years ago.
How can i write a file in PHP with encode ISO-8859-1?
Im using the function
$file = fopen("file.txt", "a");
When the file is created, it appears with encoding UTF-8 and i want it in ISO-8859-1.
UTF-8 supports all the characters found in ISO-8859-1... it's best to stick with UTF-8 as it supports the most amount of characters commonly used and will give you the least amount of problems.
This question already has answers here:
How to convert HTML entities like – to their character equivalents?
(5 answers)
Closed 7 years ago.
I have string:
tomas
there is decoded string tomas
I found that there is hec decode type : http://www.codetable.net/unicodecharacters
Does in PHP exists fuction to encode hex to latin characters ?
Those are not hex characters, but HTML entities.
PHP can decode them with html_entity_decode().
This question already has answers here:
Unicode character in PHP string
(8 answers)
Closed 8 years ago.
To decode json to chinese:
json_decode('"\ud83d\ude18\ud83d\ude18\ud83d\ude18\ud83d\ude18\u597d\u5bb6\u4f19\ud83d\ude0d\ud83d\ude0d\ud83d\ude0d"');
not works?
It works for chinese but not for smily
can you please give me any idea for it
that's not a valid JSON string -- JSON strings must be inside double quotes
Edit: took the failing example above, wrapped the utf-8 in doublequotes, and it decoded:
var_dump(json_decode('"\ud83c\udf83\ud83c\udf83\ud83c\udf83"'));
string(12) "🎃🎃🎃"
(I don't know what the glyphs should look like, I don't eve know if I have the right fonts installed, but the string decoded)
This question already has answers here:
Change foreign characters to their roman equivalent
(7 answers)
Closed 8 years ago.
Is there any possible way of doing this in PHP? Eg convert the word Québec
$str = 'Québec';
echo convert($str);
result:
Quebec
Those are called diacritics (or accents). The process of converting some text from one script to another (e.g. one with diacritics to one without) is called transliteration and PHP has a module for performing it.
You probably want something like:
transliterator_transliterate('Any-Latin; Latin-ASCII', $your_input);
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to decode numeric HTML entities in PHP
How does one remove/replace ” characters from a string?
I've tried html_entity_decode but it don't seem to work. There are other similar characters in the string that don't seem to be converted or removed.
Any ideas?
The issue is that html_entity_decode() doesn't translate numeric entities.
I added an answer to the suggested duplicate How to decode numeric HTML entities in PHP
str_replace(array('”', '”'), '', $thestring);
Here is a working example: http://codepad.org/gXrZcxaF
Does this do what you're looking for:
http://shiflett.org/blog/2005/oct/convert-smart-quotes-with-php Converting smart quotes and other characters with PHP so they display correctly
http://ca2.php.net/manual/en/function.htmlentities.php#84612 Dealing with Numeric entities in PHP (comment on the manual)