{"record":{"id":"59278e3aa1939a17","repo":"helix-editor/helix","slug":"could-not-interpret-as-a-unicode-character-co","errorCode":null,"errorMessage":"could not interpret '{}' as a Unicode character code","messagePattern":"could not interpret '(.+?)' as a Unicode character code","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"helix-view/src/expansion.rs","lineNumber":123,"sourceCode":"/// `Editor`. See `expand_variable` below for more discussion of lifetimes.\npub fn expand<'a>(editor: &Editor, token: Token<'a>) -> Result<Cow<'a, str>> {\n    // Note: see the `TokenKind` documentation for more details on how each branch should expand.\n    match token.kind {\n        TokenKind::Unquoted | TokenKind::Quoted(_) => Ok(token.content),\n        TokenKind::Expansion(ExpansionKind::Variable) => {\n            let var = Variable::from_name(&token.content)\n                .ok_or_else(|| anyhow!(\"unknown variable '{}'\", token.content))?;\n\n            expand_variable(editor, var)\n        }\n        TokenKind::Expansion(ExpansionKind::Unicode) => {\n            if let Some(ch) = u32::from_str_radix(token.content.as_ref(), 16)\n                .ok()\n                .and_then(char::from_u32)\n            {\n                Ok(Cow::Owned(ch.to_string()))\n            } else {\n                Err(anyhow!(\n                    \"could not interpret '{}' as a Unicode character code\",\n                    token.content\n                ))\n            }\n        }\n        TokenKind::Expand => expand_inner(editor, token.content),\n        TokenKind::Expansion(ExpansionKind::Shell) => expand_shell(editor, token.content),\n        TokenKind::Expansion(ExpansionKind::Register) => expand_register(editor, token.content),\n        // Note: see the docs for this variant.\n        TokenKind::ExpansionKind => unreachable!(\n            \"expansion name tokens cannot be emitted when command line validation is enabled\"\n        ),\n    }\n}\n\n/// Expand a shell command.\npub fn expand_shell<'a>(editor: &Editor, content: Cow<'a, str>) -> Result<Cow<'a, str>> {\n    use std::process::{Command, Stdio};","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-view/src/expansion.rs#L105-L141","documentation":"A Unicode expansion token (%u{...}, e.g. %u{25CF}) is expanded by parsing its content as hexadecimal with u32::from_str_radix(_, 16) and then char::from_u32. The error fires when the content is not valid hex or is a number that is not a valid Unicode scalar value (above 0x10FFFF, or in the surrogate range D800-DFFF).","triggerScenarios":"Writing %u{zzzz} (non-hex digits), %u{110000} (beyond the scalar range), or %u{D800} (unpaired surrogate); accidentally including the U+ prefix or spaces, e.g. %u{U+25CF}.","commonSituations":"Copy-pasting codepoints formatted as U+25CF from unicode.org or char maps; miscounting digits; assuming surrogate halves are addressable like in UTF-16.","solutions":["Use 1-6 hexadecimal digits without prefix: %u{25CF}, %u{1F600}.","Keep the value within 0..=0x10FFFF and outside D800-DFFF.","If you literally want text like \"%u{...}\" in output, escape the percent as %%u{...}."],"exampleFix":"# before\n :echo %u{U+25CF}\n\n# after\n :echo %u{25CF}","handlingStrategy":"validation","validationCode":"fn valid_unicode_expansion(hex: &str) -> bool {\n    u32::from_str_radix(hex, 16).ok().and_then(char::from_u32).is_some()\n}\n\nif !valid_unicode_expansion(content) {\n    return Err(anyhow!(\"'{content}' is not a hex Unicode scalar (max 10FFFF, no surrogates)\"));\n}","typeGuard":"fn parse_codepoint(hex: &str) -> Option<char> {\n    u32::from_str_radix(hex, 16).ok().and_then(char::from_u32)\n}","tryCatchPattern":"match u32::from_str_radix(hex, 16).ok().and_then(char::from_u32) {\n    Some(ch) => out.push(ch),\n    None => return Err(anyhow!(\"invalid Unicode codepoint '{hex}'\")),\n}","preventionTips":["Strip U+ prefixes, spaces, and '#x' style prefixes before submitting codepoints.","Reject values above 0x10FFFF and the D800-DFFF surrogate range up front.","Escape a literal % as %% when the digits are meant as text."],"tags":["expansion","unicode","command-line","helix","rust"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}