Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert special characters in a string to unicode?

I couldn't find an answer to this problem, having tried several answer here combined to find something that works, to no avail. An application I'm working on uses a users name to create PDF's with that name in it. However, when someones name contains a special character like "Yağmur" the pdf creator freaks out and omits this special character. However, when it gets the unicode equivalent ("Yağmur"), it prints "Yağmur" in the pdf as it should.

How do I check a name/string for any special character (regex = "[^a-z0-9 ]") and when found, replace that character with its unicode equivalent and returning the new unicoded string?

like image 538
Louis Maas Avatar asked Nov 10 '22 06:11

Louis Maas


1 Answers

I will try to give the solution in generic way as the frame work you are using is not mentioned as the part of your problem statement.

I too faced the same kind of issue long time back. This should be handled by the pdf engine if you set the text/char encoding as UTF-8. Please find how you can set encoding in your framework for pdf generation and try it out. Hope it helps !!

like image 182
Gnana Guru Avatar answered Nov 15 '22 06:11

Gnana Guru