Skip to content

Instantly share code, notes, and snippets.

@Maelan
Maelan / fix-mixed-utf8
Created Apr 10, 2016
Decodes UTF-8, interpreting ill-formed UTF-8 sequences as CP1252.
View fix-mixed-utf8
#!/usr/bin/ocaml
(*
* Reads an UTF-8 text and writes it on standard output. Invalid codes are
* regarded as CP1252-encoded characters and are converted to UTF-8.
*)
let substitute = ""
let buf = object (self)