1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! URL encoding utilities for no_std compatibility.
//!
//! This module provides URL encoding functionality that works in both std and no_std environments.
//! The encoding follows RFC 3986 standards for percent-encoding.
use Write;
use String;
use String;
/// URL encode a string according to RFC 3986.
///
/// This function percent-encodes all characters except unreserved characters
/// (ALPHA / DIGIT / "-" / "." / "_" / "~"). Spaces are encoded as '+' for
/// form-encoded data compatibility.
///
/// # Arguments
///
/// * `input` - The string to be URL encoded
///
/// # Returns
///
/// A new `String` containing the URL-encoded version of the input.
///
/// # Examples
///
/// ```
/// use bug::url_encode::encode;
///
/// // Basic encoding
/// assert_eq!(encode("hello world"), "hello+world");
///
/// // Special characters
/// assert_eq!(encode("hello@world.com"), "hello%40world.com");
///
/// // Unreserved characters remain unchanged
/// assert_eq!(encode("hello-world_123.txt~"), "hello-world_123.txt~");
///
/// // Unicode characters
/// assert_eq!(encode("café"), "caf%C3%A9");
/// ```