Page 1 of 1

HTML Character Conversion

Posted: Fri Oct 31, 2008 5:25 pm
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

Re: HTML Character Conversion

Posted: Fri Oct 31, 2008 6:05 pm
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?

Re: HTML Character Conversion

Posted: Fri Oct 31, 2008 6:13 pm
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?

Re: HTML Character Conversion

Posted: Fri Oct 31, 2008 7:56 pm
by s.dot
You can check out the function get_translation_table()