Dart 中的 urlencoding [英] urlencoding in Dart
问题描述
Dart 中是否有进行 urlencoding 的函数?我正在使用 XMLHttpRequest 对象进行 AJAX 调用,我需要对 url 进行 url 编码.
Is there a function to do urlencoding in Dart? I am doing a AJAX call using XMLHttpRequest object and I need the url to be url encoded.
我在 dartlang.org 上进行了搜索,但没有找到任何结果.
I did a search on dartlang.org, but it didn't turn up any results.
推荐答案
更新:现在支持 Dart Uri 类
Dart 的 URI 代码放置在一个名为 的单独库中dart:uri(所以它可以在 dart:html
和 dart:io
之间共享).看起来它目前不包含 urlencode
函数,所以现在你最好的选择可能是使用 this JavaScript encodeUriComponent
的 Dart 实现.
Dart's URI code is placed in a separate library called dart:uri (so it can be shared between both dart:html
and dart:io
). It looks like it currently does not include a urlencode
function so your best alternative, for now, is probably to use this Dart implementation of JavaScript's encodeUriComponent
.
这篇关于Dart 中的 urlencoding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!