X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2FmatitaGtkMisc.ml;h=6407ae35d1e8654fb89022b574704f50fea84422;hb=2135f4eb98004c55f67ae3fa52ca60d53a86d9f2;hp=a41dbffe373713d3ca3fa5858e215f801afe5a58;hpb=890221127070350c2e33aa4685398b03258aa847;p=helm.git diff --git a/matita/matitaGtkMisc.ml b/matita/matitaGtkMisc.ml index a41dbffe3..6407ae35d 100644 --- a/matita/matitaGtkMisc.ml +++ b/matita/matitaGtkMisc.ml @@ -439,3 +439,21 @@ let ask_record_choice ~(gui:#gui) ?(title= "") ?(message = "") GtkThread.main (); (match !record_no with Some n -> n | _ -> raise MatitaTypes.Cancel) +let utf8_parsed_text s floc = + let start, stop = HExtlib.loc_of_floc floc in + let start_bytes = Glib.Utf8.offset_to_pos s ~pos:0 ~off:start in + let stop_bytes = Glib.Utf8.offset_to_pos s ~pos:0 ~off:stop in + assert(stop_bytes >= start_bytes); + let bytes = stop_bytes - start_bytes in + try + String.sub s start_bytes bytes, bytes + with Invalid_argument _ -> + Printf.eprintf "%s/%d/%d\n" s start_bytes bytes; + assert false + + +let utf8_string_length s = + if BuildTimeConf.debug then + assert(Glib.Utf8.validate s); + Glib.Utf8.length s +