Page 1 of 1
htmlspecialchars
Posted: Fri May 29, 2015 6:49 pm
by Vegan
I noticed when Googling for a problem with my chess site, how to leverage PHP to convert the old format included file into something that will render fine with HTML 56 browsers
htmlspecialchars seems to be what I want
Code: Select all
<?php include $_SERVER["DOCUMENT_ROOT"] . "/tournaments/html/group1.html"; ?> <!-- Arena conveniently formats results -->
I tried
Code: Select all
echo htmlspecialchars(file_get_contents($_SERVER["DOCUMENT_ROOT"] . '/tournaments/html/group1.html'));
while the result was what I wanted, I wanted the table to draw, not the basic text shown,
what should I do to this include call to pass it through the converter?
so that the table shows properly?
Re: htmlspecialchars
Posted: Sat May 30, 2015 12:51 am
by requinix
Don't use htmlspecialchars(). That's for when you want something to not be interpreted as HTML. The opposite of what you're trying to do.
Re: htmlspecialchars
Posted: Sat May 30, 2015 7:04 am
by Vegan
then what function should I use to clean up the imported HTML file that needs to be escaped
Re: htmlspecialchars
Posted: Sat May 30, 2015 7:23 am
by requinix
Nothing? What are you trying to "clean"? If it's your HTML then you shouldn't have to do anything to it...
Re: htmlspecialchars
Posted: Sat May 30, 2015 1:46 pm
by Vegan
The problem is there are some symbols that need to be escaped and they are not which is why I was searching for some kind of functionality
this way I can have the table look cleaner and as intended
even with UEF-8
Re: htmlspecialchars
Posted: Sat May 30, 2015 7:06 pm
by requinix
You keep saying "escaped". Can you describe what problem you're trying to solve by "escaping"?
Re: htmlspecialchars
Posted: Sat May 30, 2015 7:19 pm
by Vegan
an example might make it clear
let file.html contain some non UEF-8 characters that I want to massage into UTFT
http://www.theukwebdesigncompany.com/ar ... acters.php
the . character is AKA , etc, so what I wanted to achive is to swap the problem symbols for the & etc
this way the page will render as wanted, hard coded so to speak
Re: htmlspecialchars
Posted: Sat May 30, 2015 11:32 pm
by requinix
Why not just fix the problem in the file itself? Directly.
Re: htmlspecialchars
Posted: Sun May 31, 2015 7:15 am
by Vegan
unfortunately the program that emits the crappy HTML is not open source so I cannot do anything about it, except maybe parse it which is what I have been trying to figure out
Re: htmlspecialchars
Posted: Sun May 31, 2015 6:08 pm
by requinix
Okay, well your description a couple posts up doesn't make much sense to me.
Is this a problem of character encoding? The file has characters in a known, non-UTF-8 encoding? Convert the string with
iconv or
mb_convert_encoding.
Is it messy HTML? Try applying Tidy to it.
Re: htmlspecialchars
Posted: Tue Jun 02, 2015 8:16 pm
by Vegan
I ran across another PHP function that possibly has some potential??
utf8_encode(string) // this is what I want, then I can assemble from that???
http://www.w3schools.com/php/func_xml_utf8_encode.asp