Commit c9069a0d authored by MARCHE Claude's avatar MARCHE Claude
Browse files

why3ide: Fix loading of non UTF8 source files

parent a5443911
......@@ -133,13 +133,29 @@ let (why_lang, any_lang) =
| Some _ as l -> l in
(why_lang, any_lang)
(* Borrowed from Frama-C src/gui/
Try to convert a source file either as UTF-8 or as locale. *)
let try_convert s =
if Glib.Utf8.validate s then s else Glib.Convert.locale_to_utf8 s
with Glib.Convert.Error _ ->
~fallback:"#neither UTF-8 nor locale nor ISO-8859-15#"
with Glib.Convert.Error _ as e -> Printexc.to_string e
let source_text fname =
let ic = open_in fname in
let size = in_channel_length ic in
let buf = String.create size in
really_input ic buf 0 size;
close_in ic;
try_convert buf
(* loading WhyIDE configuration *)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment