- let utf16le = CharEncoding.utf16le in
- let utf8 = CharEncoding.utf8 in
- try
- let v = CharEncoding.recode_string ~in_enc:utf16le ~out_enc:utf8 v in
- (* Registry strings include the final \0 so remove this if present. *)
- let len = UTF8.length v in
- let v =
- if len > 0 && UChar.code (UTF8.get v (len-1)) = 0 then
- String.sub v 0 (UTF8.last v)
- else
- v in
- markup_escape v
- with
- | CharEncoding.Malformed_code
- | CharEncoding.Out_of_range ->
- (* Fallback to displaying the string as hex. *)
- markup_hex_data v
+ try markup_escape (windows_string_to_utf8 v)
+ with CharEncoding.Malformed_code | CharEncoding.Out_of_range ->
+ (* Fallback to displaying the string as hex. *)
+ markup_hex_data v