Created
May 30, 2014 06:59
-
-
Save Hubbitus/db86efb2c9529ccaabb2 to your computer and use it in GitHub Desktop.
Revisions
-
Hubbitus created this gist
May 30, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ Добрый вечер. У меня какая-то странная проблема с кодировкой (UTF-8) в storage.get/set. Простой код: var t = { en: 'test', ru: 'тест' }; console.log('Object to save', t, JSON.stringify(t)); VK.api( 'storage.set' ,{ key: 'test' ,value: JSON.stringify(t) ,global: 1 } ,function(data){ alert('Success set: [' + JSON.stringify(t) + '], ' + JSON.stringify(data)); console.log('Success set: [' + JSON.stringify(t) + '], ' + JSON.stringify(data)); VK.api( 'storage.get' ,{ key: 'test' ,global: 1 } ,function(data){ console.log('Success get: [' + data.response + '], ' + JSON.stringify(data)); alert('Success get: [' + data.response + '], ' + JSON.stringify(data)); } ); } ); Соответственно с логе: Object to save Object {en: "test", ru: "тест"} {"en":"test","ru":"тест"} main.js:97 Success set: [{"en":"test","ru":"тест"}], {"response":1} main.js:107 Success get: [{"en":"test","ru":"����"}], {"response":"{\"en\":\"test\",\"ru\":\"����\"}"} Используется стандартный VK SDK (//vk.com/js/api/xd_connection.js). Причём в заголовках ответа сервера на гет (из консоли браузера Chrome): Content-Type:application/json; charset=utf-8. Но похоже всё же на то что данные уже потеряны и пришли в однобайтовой кодировке. Вроде в доке явно написано что используется юникод. Подскажите пожалуйста, что делаю не так?