Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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 _ =
  try
    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
    done
  with
  | 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
mail-lists.