如何在URL编码中使用UTF-16? [英] How to use UTF-16 in URL encoding?

查看:102
本文介绍了如何在URL编码中使用UTF-16?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用utf-8进行URL编码。我想将其转换为UTF-16。



如何实现?

解决方案

在URL中编码Unicode字符时,必须以所有URL解析器和使用者都可以理解您的URL的方式对其进行编码。



结束;在Unicode和相关标准和工具开发之后,URL由RFC扩展时,决定用于编码字符的编码(使用转义百分比)应为UTF-8,因为这意味着已建立



因此,即使您可以使用基于UTF-16的百分号转义生成URL,其他程序也无法理解它们,因此他们没用。实际上,按照定义,它们甚至都不会成为 URL。



还有一个问题,为什么您要在地球上

记住:从不使用UTF-8!对所有问题都使用UTF-16。 / strong>( N'DUUH!


Currently I am using utf-8 for URL encoding. I want to convert it to UTF-16.

How can I achieve this?

解决方案

When encoding Unicode characters in URLs, it's necessary to encode them in such a fashion that all URL parsers and consumers can understand your URLs.

To that end; when the URL was expanded by RFCs in the wake of the development of Unicode and related standards and tools, it was decided that the encoding to employ for encoding characters (using percent escapes) was to be UTF-8, as this would mean that established ASCII escapes would Just Work™.

Consequently, even if you could generate URLs with UTF-16-based percent escapes, no other program would be able to understand them, making them useless. In fact, by matter of definition, they wouldn't even be URLs.

There's also the question of why on earth you would want to use UTF-16 for anything, it being silly and all.

Remember: Never Don't Use UTF-8! (N'DUUH!)

这篇关于如何在URL编码中使用UTF-16?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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