Dart
Dart
URL Encoding and Decoding
See more Encryption Examples
Demonstrates URL encoding and decoding.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// To URL encoding a string:
final s = 'Why a > b?';
final sb = CkStringBuilder();
sb.append(s);
// URL encode the string.
sb.encode('url', 'utf-8');
// Show the URL encoded string:
final sEncoded = sb.getAsString();
print(sEncoded);
// The result is: Why%20a%20%3E%20b%3F
// If you prefer "+" instead of "%20" for SPACE chars:
final numReplaced = sb.replace('%20', '+');
print(sb.getAsString());
// Output is: Why+a+%3E+b%3F
// To decode:
sb.decode('url', 'utf-8');
print(sb.getAsString());
// Result is: Why a > b?
}