diff options
| author | Pierre-Marie Pédrot | 2015-07-29 12:12:35 +0200 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2015-07-29 12:12:35 +0200 |
| commit | e76ab0ec81040cbe99f616e8457bdc26cc6dceb6 (patch) | |
| tree | 5bcdbed2dac27feeb27caf840e8cad24e7483a9a /lib/util.ml | |
| parent | aff5a1aaeb9b50c60ff32b7d5336a44fd18428ee (diff) | |
| parent | 0dac9618c695a345f82ee302b205217fff29be29 (diff) | |
Merge branch 'v8.5'
Diffstat (limited to 'lib/util.ml')
| -rw-r--r-- | lib/util.ml | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml index a8c25f7456..a20dba0fc4 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -132,3 +132,14 @@ let map_union f g = function type iexn = Exninfo.iexn let iraise = Exninfo.iraise + +let open_utf8_file_in fname = + let is_bom s = + Int.equal (Char.code s.[0]) 0xEF && + Int.equal (Char.code s.[1]) 0xBB && + Int.equal (Char.code s.[2]) 0xBF + in + let in_chan = open_in fname in + let s = " " in + if input in_chan s 0 3 < 3 || not (is_bom s) then seek_in in_chan 0; + in_chan |
