Question

I need to convert unicode to character in PHP. I am using MySQL database to store text The text is in unicode format with collation utf8-general-ci. When I retrive those data and display, some special characters are displayed:: like "मिनिसà¥à¤•à¤°à¥à¤Ÿà¤®à¤¾ करà¥à¤•à¥‡ नजर" for the text "मिनिस्कर्टमा कर्के नजर". This is Nepali font in unicode format. I need it in character or ascii format in PHP. I have tried utf8 encode and decode but none of them worked(displays question marks ???? in decoding and "à ¤®à ¤¿à ¤¨à ¤¿à ¤¸à ¥Âà ¤•à ¤°à ¥Âà ¤Ÿà ¤®à ¤¾ à ¤•à ¤°à ¥Âà ¤•à ¥‡ à ¤¨à ¤œà ¤°" on encoding). So, how can I get ascii value or character or unicode value of each unicode characters from mysql database in PHP???

Was it helpful?

Solution 2

Ok, I got it. I used this php library and use utf8_chr_to_unicode_style function to convert each unicode charaters to code. I converted all the codes to my required font code(preeti nepali font code). That's all :).

OTHER TIPS

Chnage the collation to utf_bin and in header of your pages <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">. Hope it works.

Try function iconv.

It's a function for conversions from different encodings. Please try some at the link provided above. If you cannot manage to figure it out then comment and I will try to research more on the subject.

i have an issue related with the utf-8 charset. I've been all around the web (well, not entirely) but for quite awhile now and the best advice was and is to set the header charset to "UTF-8".

However, I was developing my web application locally on my machine using xampp (and sometimes wamp so as to get a distinction of the two when it came to debugging my code). Everything was working great =). But as soon as i uploaded it online, the result was not all that jazzy (the kind of errors you would get if you had set the headers to a different charset like "iso-8859-1"). Every header in my code has UTF-8 as the default charset, but i still got the same "hieroglyphic thingies". Then you guys gave me the idea that the issue isn't my code but the php.ini that was running it.. Turns out my local machine was running php 5.5 and the cpanel where i had uploaded my web application was running native php 5.3. Well, when i changed the version of php that my cpanel was set by default from Native PHP 5.3 to PHP 5.5, believe you me guys =) it worked like a charm just like as if i was right there at the localhost of machine.

NOTE: Please, if you got the same problem as i did, just make sure your PHP is 5.5 version.. I'm posting this coz i feel you guys. Cheers!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top