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
Camomile library tutorial/examples?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-09-06 (07:41)
From: dmitry grebeniuk <gdsfh1@g...>
Subject: Re: [Caml-list] Camomile library tutorial/examples?
> Recently I tried to add some unicode support to my project (for instance I need to convert Cyrillic characters from uppercase to lowercase and vice versa).

  I don't know of any good documentation on Camomile, but here is a
code that converts line from terminal to uppercase and lowercase,
assuming that your terminal's encoding is utf8.

===== camotest.ml =====
open Printf
module PREF = CamomileLibrary.Default.Camomile
module CE = PREF.CharEncoding
module CM = PREF.CaseMap.Make(PREF.UTF8)

let _ =
    while true do printf "> %!";
      let line = input_line stdin in
      let up = CM.uppercase line
      and low = CM.lowercase line
      in printf "ORIG : %s\nUPPER: %s\nLOWER: %s\n%!" line up low
  | End_of_file -> ()
===== / camotest.ml =====

$ ocamlfind ocamlc -package camomile -linkpkg camotest.ml -o camotest
$ ./camotest

btw, if you speak russian (as I can guess), you can join the jabber conference
ocaml@conference.jabber.ru , some questions are solved faster than via