fix_unicode_point

Function fix_unicode_point 

Source
fn fix_unicode_point(json: &str) -> Result<String>
Expand description

Normalizes a JSON string by converting Rust-style Unicode escape sequences to JSON-compatible format.

The input is scanned for Rust-style Unicode code point escapes of the form \\u{H...} (a backslash, u, an opening brace, followed by 1–6 hexadecimal digits, and a closing brace). Each such escape is converted into JSON-compatible UTF‑16 escape sequences:

  • For code points in the Basic Multilingual Plane (≤ 0xFFFF), the escape is converted to a single JSON \\uXXXX sequence with four uppercase hex digits.
  • For code points above 0xFFFF and less than Unicode max code point 0x10FFFF, the code point is encoded as a UTF‑16 surrogate pair and emitted as two consecutive \\uXXXX sequences (as JSON format required).

After this normalization, the function returns the normalized string