开发者

Do django ORM (or Databases or Web Browsers) normalize string encodings for storage/submission?

Since there are multiple ways to encode non-ascii strings - does Django ORM make any effort to normalize the encoding, or I have to do it myself?

Or will datab开发者_StackOverflowase do that? How about web browsers?

I'd like to make sure that strings are findable regardless of normalization form of the original input, and allow matching string entered by different methods - e.g. web, command line, etc.

Thanks.


If you are searching in your database it will depend on your encoding and collation. Generally the database is fairly good about hiding the details of this from you.

If you are accepting unicode characters you will need to make some small effort to make sure they're not decoded as ascii accidentally. This is normally easy assuming you're always starting from a unicode position.

In python unicode strings begin with a 'u':

my_str = u'Hey, a unicode thing'

As far as Django is concerned, as long as things stay unicode the entire way there are no issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜