Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
c9069a0d
Commit
c9069a0d
authored
Nov 16, 2013
by
MARCHE Claude
Browse files
why3ide: Fix loading of non UTF8 source files
parent
a5443911
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ide/gmain.ml
View file @
c9069a0d
...
...
@@ -133,13 +133,29 @@ let (why_lang, any_lang) =
|
Some
_
as
l
->
l
in
(
why_lang
,
any_lang
)
(* Borrowed from Frama-C src/gui/source_manager.ml:
Try to convert a source file either as UTF-8 or as locale. *)
let
try_convert
s
=
try
if
Glib
.
Utf8
.
validate
s
then
s
else
Glib
.
Convert
.
locale_to_utf8
s
with
Glib
.
Convert
.
Error
_
->
try
Glib
.
Convert
.
convert_with_fallback
~
fallback
:
"#neither UTF-8 nor locale nor ISO-8859-15#"
~
to_codeset
:
"UTF-8"
~
from_codeset
:
"ISO_8859-15"
s
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
;
buf
try_convert
buf
(********************************)
(* loading WhyIDE configuration *)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment