We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3e3e2aa commit 3144f86Copy full SHA for 3144f86
idna/src/punycode.rs
@@ -143,11 +143,10 @@ pub fn encode_str(input: &str) -> Option<String> {
143
/// 63 encoded bytes, the DNS limit on domain name labels.
144
pub fn encode(input: &[char]) -> Option<String> {
145
// Handle "basic" (ASCII) code points. They are encoded as-is.
146
- let output_bytes = input
+ let mut output : String = input
147
.iter()
148
- .filter_map(|&c| if c.is_ascii() { Some(c as u8) } else { None })
+ .filter(|&c| c.is_ascii())
149
.collect();
150
- let mut output = unsafe { String::from_utf8_unchecked(output_bytes) };
151
let basic_length = output.len() as u32;
152
if basic_length > 0 {
153
output.push_str("-")
0 commit comments