HTML Character Conversion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

HTML Character Conversion

Post by Parody »

I'm in need of a function that can convert between html character codes e.g. $ for $ and plain text, and it needs to be the whole character set, not just some of them. So before I start the laborious process of writing a very long replacements list I thought I'd check to see if anyone else has one.

I was going to use the list at http://www.ascii.cl/htmlcodes.htm, is this the full set?

Also, what is the best way to go about this? I was just going to do loads of str_replace, but I realize that in this situation it may be flawed in that it will replace characters in the replacements.

If someone out there can save me from a lot of wasted time then please do :D
Moargazm
Forum Newbie
Posts: 6
Joined: Fri Oct 31, 2008 2:08 pm

Re: HTML Character Conversion

Post by Moargazm »

Err, I can't really think of what you'd need to do like that, that you can't just escape.

What are you trying to do?
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Re: HTML Character Conversion

Post by Parody »

I'm making a cross platform database program and I can't predict with certainty which characters might affect scripts so the only way I can make it 'unbreakable' is to use a character set of only numbers and & # and ; which can be converted into letter representatives and so have only letters and numbers representing any possible string. It makes sense to me.

Any tips or ideas on where I can get more info?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: HTML Character Conversion

Post by s.dot »

You can check out the function get_translation_table()
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply