Should a Dart web server use UTF-16 encoding for e

2019-09-09 06:39发布

I'm running a Dart web server, with Dart on the client side as well. The web data is saved in files and in a Postgres database.

Since dartlang is UTF-16 (because Webkit strings are UTF-16), does it make sense to go to UTF-16 whole hog? That is, instead of default UTF-8, make the following native UTF-16:

  • files (web pages)
  • database (web data)
  • HTML encoding

It seems there would be a small hit on data transfer, but at the same time more efficient in the server and browser, and there would be less of a chance for accidental screw-ups.

1条回答
你好瞎i
2楼-- · 2019-09-09 07:09

PostgreSQL does not support UTF-16 encoding, which limits what you are talking about doing. One of the big issues you are likely to run into elsewhere is that UTF-16 allows embedded nulls, which messes up C string manipulations, while UTF-8 is far more C friendly. For this reason, to be honest, I would try to standardize on UTF-8 to the extent possible.

查看更多
登录 后发表回答