Dart web服务器应该使用UTF-16编码吗? [英] Should a Dart web server use UTF-16 encoding for everything?

查看:506
本文介绍了Dart web服务器应该使用UTF-16编码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个Dart web服务器,在客户端也有Dart。网络数据保存在文件和Postgres数据库中。

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.

由于dartlang是UTF-16(因为Webkit字符串是UTF-16),所以是有意义的到UTF-16全猪?也就是说,不要使用默认的UTF-8,请生成以下原生UTF-16:

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:


  • 文件(网页)

  • 数据库(网络数据)

  • HTML编码

会对数据传输造成很小的冲击,但同时在服务器和浏览器中效率会更高,并且不会有意外误操作的机会。

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不支持UTF-16编码,这限制了你在说什么。你可能在其他地方遇到的一个大问题是,UTF-16允许嵌入的null,这会扰乱C字符串操作,而UTF-8是更友好的。基于这个原因,老实说,我会尽量在UTF-8上尽可能标准化。

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.

这篇关于Dart web服务器应该使用UTF-16编码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆