View Single Post
Old 11-28-2012, 08:23 PM   PM User | #18
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,468
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by RickP View Post
It fails when trying to add to localStorage the following deflated value:

"‹®VÊLQ²:J9‰•©E@”¡£”œ_ZTœ
2jc"

I get "Invalid argument." Note there is a return character there so not sure if that's messing it up.

This came from the string:

"[{"id":"id","player":"player","course":"course"}]"


Any ideas why that would be? Nothing in that string seems odd. It does work for some other strings I've done.
ok. i looked into it.

Firstly, "It" doesn't fail, this is an IE localStorage problem, not a string problem or an issue with my functions.

my functions are fine in IE 6+



it seems that IE, even IE10 has an issue with localStorage.
this is a bug with IE's localStoage, not the code i posted, but i'll try to help anyway.

in chrome and firefox, this is true:
localStorage['temp']=unescape("%01");
localStorage['temp']==unescape("%01")
but in IE, it's false (9+10) or throws (7+8)

so, we need to fix IE, and IE only, both the 8 and 9/10 branch. Fun!

this alternate routine works on 8+9+10:

Code:
var code=deflate('[{"id":"id","player":"player","course":"course"}]');

localStorage['_temp']=escape(code);
inflate(unescape(localStorage['_temp']));
you may want to use a custom save(key, value) function instead of just using localStorage[key]=value, so that you have a chance in your normal workflow to handle IE's specific needs. it's also a chance to bake-in a date and other machine-gathered meta about the stored values.

just so there's no confusion to anyone reading this a year from now, one last time; the functions work in IE, localStorage has minor compat issues that require special handling.

why IE can't localStorage all the chars possibilities i don't know, but i appreciate your pointing this out, it's good to know.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%

Last edited by rnd me; 11-28-2012 at 08:28 PM..
rnd me is offline   Reply With Quote