Search code examples
phpunicodehtml-entitiessharethis

How to convert unicode charaters to unicode decimal entities php?


I have unicode characters in MySQL tables. I will print the data in the web pages. While printing it in the pages I am generating the 'Share This' buttons dynamically to share each record in that table (which is in Punjabi).

So the output in the page looks fine. But while sharing the same content in 'Share This' the destination page shows some unknown characters. Later I found that the data sent across the websites should be in Unicode Entity format (like ਆ this will print this '').

Now my tables have the values like ਜ ਝ ਞ ਟ ਠ ਡ ਢ.

I want to convert these data like ਜ ਝ ਞ ਟ ਠ ਡ ਢ in PHP.

Please help me in this.


The above issue fixed. But the Share This is still making issues while displaying the Unicode characters. Below is the output in the browser.

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>`
<script type="text/javascript">
stLight.options({
    publisher:'12345'
});
</script>
<span class="st_facebook" st_title="ੴਸਤਿ ਨਾਮੁ ਕਰਤਾ ਪੁਰਖੁ ਨਿਰਭਉ ਨਿਰਵੈਰੁ ਅਕਾਲ ਮੂਰਤਿ ਅਜੂਨੀ ਸੈਭੰ ਗੁਰ ਪ੍ਰਸਾਦਿ ॥" st_url="http://sitelink/"></span>

Thanks in advance, Abu Sithik


Solution

  • You should probably use url_encode the text when outputting the href of your <a> tag.