Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Font encoding issue

Hi, so what im trying to do is create a very simple text converter. I plan to have a whole array of different character sets and then convert normal input into any one of them at random.

My problem is when im taking a character from the desired font, i assume the encoding is getting messed up and returning either a weird symbol or just a ?. I've tried various encoding functions but still no luck. If i just print out $font it displays as it should but it seems when i take a single character from the set, it starts to mess up.

Code: http://pastebin.com/3CS6TKXA

My current idea is to take the position from the normal font and use that position to get the matching character from the new font. I'm not sure if that's the best way, but it seems to get the job done.

Thanks!😁
(Jan 31, 2017 11:22 AM)Yani Wrote:  I think you should learn a bit more about this stuff because to me it seems that you're mixing everything up. Encodings, characters sets and fonts are all different things. If you're doing what I think you're doing you don't even need to think about "Fonts".

I know. I have the "font" in my function but as soon as i take a character from the string, it doesn't get displayed how it should. But if i print the string untouched, it works fine.


I managed to get this fixed by changing my approach to it. I decided to use an array for each character, its a little lengthier, but works great. Here's the code if anyone wants it: http://pastebin.com/LekRdWiU

You may want to add some checks for other symbols or whatever if you decide to ever use it.
Try this ..
(Jan 31, 2017 04:01 PM)Ryuga Wrote:  Try this ..

Thank you, this works great. Do you mind explaining where you got the "~~u" from? I know its a pattern, but im clueless as to where i would come up with that.
Actually, I got this from http://php.net/manual/en/function.mb-split.php#117588 - but from my understanding.. The tildes are delimeters and the 'u' modifier is there just to make preg_split know that $input is gonna be a UTF-8 encoded string (expect multibyte chars) .. 🎉


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by ZykerJan 14, 2022 03:05 AM 8 272 Jan 14, 2022 03:05 AM
Last Post: lunatichero
[Javascript]  by GeatzoMay 11, 2020 08:35 PM 2 101 May 11, 2020 08:35 PM
Last Post: SIM-3991524
[PHP] by sarciszewskiMar 18, 2016 05:49 PM 8 191 Mar 18, 2016 05:49 PM
Last Post: sarciszewski