查询变量中可以使用哪些有效的 URL 字符?

发布于 2024-09-04 19:36:34 字数 377 浏览 1 评论 0原文

URL 查询变量中可以使用哪些有效字符?

我这样问是因为我想通过使用最大的字符集创建最小字符串长度的 GUID,只要它们可以作为 URL 查询变量传递(www.StackOverflow.com?query=guiddaf09834fasnv)

编辑

如果要编码将 UUID/GUID 或以字节数组表示的任何其他信息转换为 url 友好的字符串,您可以在 Apache Commons 代码库

Base64.encodeBase64URLSafeString(byte[])

What are the valid characters that can be used in a URL query variable?

I'm asking because I would like to create GUIDs of minimal string length by using the largest character set so long as they can be passed as a URL query variable (www.StackOverflow.com?query=guiddaf09834fasnv)

Edit

If you want to encode a UUID/GUID or any other information represented in a byte array into a url-friendly string, you can use this method in the Apache Commons Code library:

Base64.encodeBase64URLSafeString(byte[])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-09-11 19:36:34

如有疑问,请访问 RFC

注意:查询变量的处理方式与 URL 其余部分的处理方式不同。

来自“2.2. URL字符编码问题”部分

...只有字母数字、特殊字符“$-_.+!*'(),”以及用于其保留目的的保留字符可以在 URL 中以未编码的方式使用。

When in doubt, just go to the RFC.

Note: A query variable is not dealt with any differently then the rest of the URL.

From the section "2.2. URL Character Encoding Issues"

... only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文