Saturday, July 18, 2015

Watch that UTF8 when serving JSON

Im currently messing about with Node.JS after deploying a droplet on DigitalOcean.  Heard alot of people talking about DigitalOcean before, but never tried it untill now. That server was so incredibly simple to set up, i'm speechless.


I will post a guide on how to quickly get multiple node sessions running in a bit, but for now i will just mention this little detail i ran across. I had a bit of a head-scratcher when writing my first Node service for serving up some Json data. It worked nice and dandy, but coming from Norway my Json data contains alot of special characters, like Æ, Ø and Å.

These characters went missing when my file was being served. Turns out it was just bad encoding. Setting the encoding to UTF8 solved the problem. So check that!

No comments:

Post a Comment