首页 > 解决方案 > 如何在 Flutter 或 Dart 中将字符串编码为 RFC 3986?

问题描述

我正在尝试将字符串编码为 RFC 3986。我找到了 Uri.encodeComponent 方法,但它将字符串编码为 RFC 2396。基本上,我正在寻找 PHP 中的方法的替代方法,即 rawurlencode。在 php 中,此方法将字符串编码为 RFC 3986。在 Dart 或 Flutter 中有没有这样的方法?

标签: flutterdarturi

解决方案


所以我从 Dart SDK gitter Channel 找到了答案。使用 Uri.encodeQueryComponent 它与 encodeComponent 相同,但不是使用 RFC 2396 兼容表,而是使用 RFC 3986。


推荐阅读