English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Storing UTF-8 in plain strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-08-12 (21:34)
From: Jake Donham <jake@d...>
Subject: Re: [Caml-list] Storing UTF-8 in plain strings
On Wed, Aug 12, 2009 at 1:51 PM, Edgar Friendly<thelema314@gmail.com> wrote:
>> - If the source is invalid UTF-8 in any way, Ulex will raise Utf8.MalFormed.
>>   I can therefore assume in subsequent steps that the source is compliant.
> This is the weakest assumption of the four - Ulex could parse and only
> raise MalFormed on some errors.  I'm no expert on Ulex, though...

The original poster might be interested in the Netconversion module
from Ocamlnet, which is designed to work with UTF-8 stored in OCaml
strings. In particular it has a function

  Netconversion.verify `Enc_utf8 s

which checks that s is a valid UTF-8 string. It also has equivalents
for String.{get,sub,length}.