Link to home
Start Free TrialLog in
Avatar of intellisource
intellisourceFlag for South Africa

asked on

inserting multiple no break space into list select via xml retrieved from server side

hi there,
i am having some trouble in that it is populating \u00a0 instead of a nobreak space into the list select.
how should i populate a nobreak space from php generated xml into the <header></header> tag so it can be displayed correctly in the web page via the javascript?
xml excerpt:
<header>#110010451\u00a0\u00a0SENT\u00a0\u00a0\u00a0\u00a0\u00a02011-10-29 02:48:53\u00a0\u00a0Pierre du Toit ( pierre@greywacke.co.za )</header>

Open in new window

&nbsp; instead also doesn't work - i need to save the no break space unicode character in the database so they populate. perhaps alt+0160 when saving to the database? 0o
sincerely,
Pierre du Toit.
lead-manager.jpg
Avatar of intellisource
intellisource
Flag of South Africa image

ASKER

unfortunately this did not work. seems i am having trouble with posting the ajax request encoding this field in the encodeURIComponent function.
once received by the handler, it saves the configurable text to mysql.
this is then retrieved from the database as the following
#%LEADREFERENCE%  %LEADSUCCESS%  %LEADCREATED%  %CONSUMERNAME% ( %CONSUMEREMAIL% )

Open in new window

and the flags are populated.
the %LEADSUCCESS% flag is populated by either "SENT   " or "UNSENT" depending on the lead value with the following php.
			case "LEADSUCCESS":
				if ($GLOBALS["leadsuccess"]) {
					return "SENT   ";
				} else {
					return "UNSENT";
				}
				break;

Open in new window

however from the first screenshot it can clearly be seen that the nobreak spaces do not populate as expected. the second screenshot gives an example of them doing this, where they are manually put in by javascript inbetween the variables retrieved from xml.
the whole issue of this excersize is to make the select list "headers", configurable.
just seems i am going about it the wrong way to populate the "headers" from php generated xml so that the nobreak spaces display properly.
could somebody please assist!
lead-manager-2.jpg
lead-manager-3.jpg
Avatar of ukerandi
use <br> tag to break
and another question - where does the  come from? 0o
the database stored values are:

Open in new window

and the replacement values are:

Open in new window

yet SENT get's 3 Â characters before every nobreak space 0o
somebody please help...
apologies - forgot to paste the strings above. here they are.
#%LEADREFERENCE%  %LEADSUCCESS%  %LEADCREATED%  %CONSUMERNAME% ( %CONSUMEREMAIL% )

Open in new window

"SENT   "

Open in new window

somehow the php is replacing those nobreak space characters (alt+0160) with " ". how can i get around this? all my php documents are utf-8 and as far as i know so is php's default charset.
Hello intellisource,

I did not understand your problem exactly, but it seems to have problem with character set.

Did you check it by changing character set of your browser?

can you provide link to your page? if it is online.

can you provide detail code?


is it possible for you to replace space with &nbsp; ?

Thank You.

Amar.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
unfortunately i could not use &nbsp; as noted in my previous post - instead i used &#0x00A0;
thanks ray_paseur - this has been the most straightforward way to do it. :)
as can be seen in the screenshot i will post as a reply - it is working now! :D
sincerely, Pierre.
lol i already got the answer on the following page:
http://www.cs.sfu.ca/~ggbaker/reference/characters/#char00A0 ;)
lead-manager-4.jpg
still, thanks a lot for the help every body! :)
I think your character-set encodings must be wrong, and I am trying to figure out why you need UTF-8.  I extracted the xmlentities function from the code snippet at ID:37057032 and added some data visualization to it.  It does not appear to work correctly in either ISO-8859-1 or UTF-8.  You can install this little test script and run it to see what it is doing to the data.  Try it this way once, then make a change on line 7 to charset=utf-8 and you will see that it has serious issues.

Can you please tell us what characters are causing you to need UTF-8?  Thanks, ~Ray
<?php // RAY_temp_intellisource.php ?>

<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>

<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />

<?php
error_reporting(E_ALL);
echo "<pre>";

// EXTRACTED FROM THE POST AT EE
// xmlentities function also from global include
function xmlentities($value)
{
    // replace characters
    if (is_array($value))
    {
        foreach ($value as $key => $val)
        {
            $value[$key] = xmlentities($val);
        }
    }
    else
    {
        //replace $value's invalid xml characters with entities and unicode characters
        // used with Hex NCR's (Hexadecimal Numeric Character Representations).
        $patterns = array(
                '&',            // ampersand symbol
                '<',            // less than symbol
                '>',            // greater than symbol
                '"',            // double quotation mark
                '©',            // (c) copyright symbols
                'ë',            // e with diaresis
                'è',            // e with grave
                'é',            // e with acute
                '"',            // left slanting double quotation mark
                '"'             // right slanting double quotation mark
            );
        $replacements = array(
                '&amp;',
                '&lt;',
                '&gt;',
                '&quot;',
                '&#x00A9;',
                '&#x00EB;',
                '&#x00E8;',
                '&#x00E9;',
                '&#x201C;',
                '&#x201D;'
            );
        // ADD DATA VISUALIZATION
        var_dump($patterns);
        var_dump($replacements);

        $value = utf8_encode($value);    // convert string to unicode to replace characters
        $value = str_replace($patterns, $replacements, $value);
    }
    return $value;
}

// TEST THE FUNCTION
$x = '&<>"©ëèé""';
print_r(xmlEntities($x));

Open in new window

OK, great!  best of luck with it, ~Ray