Jump to content

elg2001

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

elg2001's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this seems like a rather trivial matter, so if anyone can help I would greatly appreciate it.
  2. Hi,   I'm using PHP5's DOM API (http://www.php.net/manual/en/ref.dom.php) to build a XHTML 1.1 page. I can successfully create a DOMDocument object, but how do I modify the DOCTYPE of the DOMDocument object? Please note that the DOMDocument::doctype property is read-only. In a nutshell, I'd like to build one very simple XHTML 1.1 compliant web page using just the DOM API.
  3. will do. thanks! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
  4. Is isset($_COOKIE['cookie_name']) the best way to check if a certain cookie named [i]cookie_name[/i] exists? Previously, I was using if(strlen($_COOKIE['cookie_name']) > 0) but that generates errors. Basically, what is the best way to check for the existence of a cookie? isset() or otherwise?
  5. thanks! I've made some progress because of your help. I had to add the ENT_COMPAT, and 'UTF-8' parameters when calling the htmlentities function. now the delta character works. however, certain other characters from the "Character Map" program do not show up correctly, such as russian characters. here's the line of code in question after the changes: [code]$bodytext = $doc->createTextNode(str_replace(array("\r\n", "\r", "\n", '  '), array('<br />', '<br />', '<br />', '&nbsp;&nbsp;'), htmlspecialchars(stripslashes($_POST['body']), ENT_COMPAT, 'UTF-8')));[/code] for whatever reason, if i add utf8_encode, the characters get all messed up. but now i think htmlspecial chars is taking care of changing the encoding to UTF-8, so doing it a second time with utf8_encode is the reason for the garbage characters?
  6. that didnt fix it, but you did help me point out a syntax error in my <meta> tag :) i'll use a delta symbol Δ as an example. after i submit it, when i ssh into the linux server and then examine the .xml file the text is stored in, the delta symbol gets stored as [b]&amp;Icirc;Â^Ô[/b] so my guess is there's some problem with either transmitting the character to the server, or the server-side php script is handling the delta symbol incorrectly. There must be something I can do to fix it because wikipedia.com uses php and is able to transmit delta symbols just fine. What can I do?
  7. Hi, I've done alot of looking into this. Wikipedia's website sends UTF-8 text and can embed unicode characters in a page (such as a greek delta symbol). However, when I try to accomplish the same thing in PHP, when I submit a delta symbol Δ using a text area and an html form with method="post", it gets stored in an XML file as Δ. Basically, non-english language characters show up as garbage. The code to store the <textarea>'s content is as follows: [code]$body = $doc->createElement('body'); $bodytext = $doc->createTextNode(utf8_encode(str_replace('  ', '&nbsp;&nbsp;', str_replace("\n", '<br />', str_replace("\r", '<br />', str_replace("\r\n", '<br />', htmlentities(stripslashes($_POST['body'])))))))); $body->appendChild($bodytext); $post->appendChild($body); $doc->documentElement->insertBefore($post, $doc->documentElement->firstChild); $doc->formatOutput = false; $doc->save($fPath);[/code] I'm using the utf8_encode() function because without it there, PHP throws an exception that the submitted character is not a valid XML character. The XML file's encoding is UTF-8, declared as follows: [code]$doc = new DOMDocument('1.0', 'UTF-8');[/code] Can anyone steer me in the right direction?
  8. and by the way, if I DO use utf8_encode(), it works. however, all non-ascii characters are replaced with junk characters, so I end up with a valid XML document but an invalid XHTML document.
  9. Hi, I've done alot of looking into this. Wikipedia's website sends UTF-8 text and can embed unicode characters in a page (such as a greek delta symbol). However, when I try to accomplish the same thing in PHP, when I submit a delta symbol using a text area and an html form with [b]method="post"[/b], it gets stored in an XML file. Then when I try to view what i have submitted in html, I see [b]Δ[/b] where the delta symbol should be. The code to store the <textarea>'s content is as follows: [code]$body = $doc->createElement('body'); $bodytext = $doc->createTextNode(utf8_encode(str_replace('  ', '&nbsp;&nbsp;', str_replace("\n", '<br />', str_replace("\r", '<br />', str_replace("\r\n", '<br />', htmlentities(stripslashes($_POST['body'])))))))); $body->appendChild($bodytext); $post->appendChild($body); $doc->documentElement->insertBefore($post, $doc->documentElement->firstChild); $doc->formatOutput = false; $doc->save($fPath);[/code] I'm using the [b]utf8_encode()[/b] function because without it there, PHP throws an exception that the submitted character is not a valid XML character. The XML file's encoding is UTF-8, declared as follows: [code]$doc = new DOMDocument('1.0', 'UTF-8');[/code] Can anyone steer me in the right direction?
  10. Hi, I'm having some trouble with the backend of my website. It's blog software that takes the input from a text field (title) and textarea (body contents) and stores it into an XML node in UTF-8. However, occasionally I'll get a validator.w3.org validation error on my website saying the following: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Error Line 14 column 167: non SGML character number 156[/quote] for example. I believe it's a unicode character, but i'm not sure. Basically, are there any built-in functions that will translate any input text to a valid UTF-8 character? If there is not an acceptable replacement, then use a particular character to replace unrecognizable characters. For instance, a double width dash shows up as invalid on my site, so replace that character with a question mark.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.