Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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.

===== =====
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 -> ()
===== / =====

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

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