JSON charset problem when sending to firebase from

2019-08-18 08:22发布

问题:

I'm saving data to firebase RTDB through JS SDK (6.3.1) using:

 firebase.initializeApp(firebaseConfig);
  var data={
      "name":"Česká republika"
  };
  var key = firebase.database().ref().child('areas').push(data).key;

There's a problem with special characters, when I view them in Firebase console. It's scary, but firebase SOMETIMES gets the characters right and sometimes doesn't. The following output was achieved only by refreshing the script (The script file is encoded in UTF-8):

Also sending characters in a form like \u00e9 doesn't help. They too are received sometimes nicely, sometimes not. Thanks for your ideas!

回答1:

This was in issue in a downstream dependency (the JavaScript minifier), which caused encoding problems on some edge cases.

The problem has been solved in version 6.3.4 of the JavaScript SDK, so I recommend upgrading to the latest version if you encounter this problem.