Problem with serialize and unserialize on DND (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Problem with serialize and unserialize on DND
|
|
|
|
Problem with serialize and unserialize on DND 5 Months, 4 Weeks ago
|
Karma: 0
|
|
Hello ,
I have a strange problem when I serialze my titel of my Thumbnail in a GtkIconview they are in Latin1 codepage
and then unserialize it in my drop function there is nothing in my data and this only happens if there are some typical french accents like é or ç in the words:
Here is my code I use to serialize:
$selection = $widget->get_selected_items();
if (count($selection)==0) return; // return if there's no selection
foreach($selection as $el)
{
$iter_filter = $this->_modelfilter->get_iter($el[0]);
$titel = $this->_modelfilter->get_value($iter_filter,0);
$filepath = $this->_modelfilter->get_value($iter_filter,2);
$path = $el[0];
$elements_to_send[]=array($titel,$filepath);
}
$data->set_text(serialize($elements_to_send));
}
and in the on_drop function when I do
$data = unserialize($data->data);
there is nothing in the $data variable if I used some specialchars.
I already tried with htmlspecialchars and then htmlspecialchars_decode but it stays the same.
Somebody know;
$elements_to_send[]=array($titel,$filepath);
}
$data->set_text(serialize($elements_to_send));
}
and in the on_drop function when I do
$data = unserialize($data->data);
there is nothing in the $data variable if I used some specialchars.
I already tried with htmlspecialchars and then htmlspecialchars_decode but it stays the same.
Somebody knows how to prevent this ?
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 323
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Problem with serialize and unserialize on DND 5 Months, 4 Weeks ago
|
Karma: 0
|
|
Hello ,
Thanks for the solution
offcourse the solution of kksou I already thought of also
but this I find not such a good object oriented way.
And the solution of Jake just doesn't work.
for the set_text
can't we get a function where we can add a pointer in the data to an array or something.
I searched to now what the context variable is and what is inside maybe there is a solution?
thanks for all your great work.
Wim Stockman
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 323
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Problem with serialize and unserialize on DND 5 Months, 4 Weeks ago
|
Karma: 0
|
|
Hello ,
I found a solution. Thanks to Jake and Kksou.
instead of using the serialize function. I use the implode function to create my string out of an array with is delimited by \x10 char.
Now the dnd works fine. But I have another issue with characters before the drop I have this as titel:
"Yves Rhayé" and after the drop I have "Yves Rhay\u00e9"
problem something with the character set but what.
Thanks for all the great support
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Problem with serialize and unserialize on DND 5 Months, 3 Weeks ago
|
Karma: 0
|
|
I think I know where the problem is.
Does the gtkselectiodata->Set_Text function convert the string into uris format ?
and how can I convert it back then ?
thank you.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Problem with serialize and unserialize on DND 5 Months, 3 Weeks ago
|
Karma: 0
|
|
Hello I was on the good way finally found the solution.
you have to use the urlencode($your_string) and everything works fine.
You don't even need to uncode it. The get_text() does this for you.
Finally we can go the hole OOP way.
Thanks for all the support
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
|