PDA

View Full Version : strange symbol showing up.


bazz
08-06-2008, 03:24 AM
I am working on a script which receives the params form a form.

when I output the params I get this strange symbol between the outputs.

what is it?

it seems only to show if there are two things in the value part or two in the keys part.


key=0 ::
key=1 ::
key=Continue with Booking ::
key=Flowers :: yes�Bouquet in a Vase
key=Pillows :: yes�Hollow-Fibre Pillow
key=number_of_adults :: 1
key=number_of_children :: 0
key=submit :: Continue with Booking
key=yes�Bouquet in a Vase ::
key=yes�Hollow-Fibre Pillow ::



here's my params code.



my $query = CGI->new;
my %params = $query->Vars;

# loop thru hash and remove dodgey chars
while (my ($key, $value) = each(%params))
{
if ($key =~ /^\;+$/)
{
#print qq( dodgey input);
$key =~ s/;//g;
}

if ($value =~ /^\;+$/)
{
#print qq( dodgey input);
$value =~ s/;//g;
}
}

foreach my $key (sort %params)
{
print qq( key=$key :: $params{$key} <br /> );
}




bazz

KevinADC
08-06-2008, 06:54 AM
do you mean the "::" ? You told your perl script to print it.

print qq( key=$key :: $params{$key} <br /> );

this line :

foreach my $key (sort %params)

should be:

foreach my $key (sort keys %params)

bazz
08-06-2008, 01:45 PM
Hi Kevin, no; I didn't mean the ::

I meant the small square, with two rows, each of two letters, like this

FF
FD

I have highlighted them in my first post.

I have subsequently discovered that they appear only if there are two values assigned to the same key. but I thought that was the whole point of a hash - that you could do that?

Thanks for the reminder tip about the 'keys'

bazz

oesxyl
08-06-2008, 04:15 PM
Hi Kevin, no; I didn't mean the ::

I meant the small square, with two rows, each of two letters, like this

FF
FD

I have highlighted them in my first post.

I have subsequently discovered that they appear only if there are two values assigned to the same key. but I thought that was the whole point of a hash - that you could do that?

Thanks for the reminder tip about the 'keys'

bazz
I guess that this come from improper encoding. Somewhere is
probably mixed utf-8 and some windows stuff. For example
you get from a form the text as win-1521 and when is passed to the script is interpreted as utf-8.
try to format output using html tags, for example using <pre>,
and see what you get.

PS: there is another posibility, missing font to display some chars. I don't think this is your case because I guess you use only english.

regards

KevinADC
08-06-2008, 06:23 PM
Hi Kevin, no; I didn't mean the ::

I meant the small square, with two rows, each of two letters, like this

FF
FD

I have highlighted them in my first post.

I have subsequently discovered that they appear only if there are two values assigned to the same key. but I thought that was the whole point of a hash - that you could do that?

Thanks for the reminder tip about the 'keys'

bazz

I don't see any small squares with FF or FD in your post. Use Data::Dumper to print out your data structure.

netroact
08-07-2008, 05:40 AM
If you look in the source of this forum page, you will see the square is ascii produced by:


\&\#65533\; (BACKSLASHES ARE MINE)


Perhaps there's an open font tag or something in your form html code, or maybe special characters.