简体   繁体   中英

Should a Dart web server use UTF-16 encoding for everything?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM