From: Philippe Strauss <philippe@strauss-acoustics.ch>
To: caml-list@inria.fr
Subject: Re: [Caml-list] ocaml-pcre and UTF-8
Date: Thu, 16 Feb 2012 11:18:58 +0100 [thread overview]
Message-ID: <25EC3048-818F-49DA-9721-86C83BE7E18F@strauss-acoustics.ch> (raw)
In-Reply-To: <32FE3555-556A-43AC-8B1B-9A4AF08DBA02@strauss-acoustics.ch>
Oh found something on the PLEAC and man pcrepattern :
let res_w = "^([\\p{Latin}\\-]+)$"
Le 16 févr. 2012 à 10:29, Philippe Strauss a écrit :
> Hello caml'ers,
>
> How do I convince PCRE to be UTF-8 friendly? example:
>
> --
> open Pcre
>
> external show : 'a -> string = "%show"
>
> let recomp = regexp ~flags:[`UTF8; `CASELESS]
>
> let res_w = "(*UTF8)^(\w+)$"
> let rec_w = recomp res_w
>
> let accents = ["blurb"; "toxicité"; "velléités"; "à"; "où"; "über"; "marie-jeanne"]
>
> let () =
> Printf.printf "config_utf8=%b\n" Pcre.config_utf8 ;
> List.iter (fun word ->
> try
> let sub = Pcre.extract_opt ~full_match:false ~rex:rec_w word in
> print_endline (show sub)
> with Not_found -> Printf.eprintf "Not_found was raised on \"%s\" :-(\n%!" word
> ) accents
> --
>
> at least on my setup it gives:
>
> --
> philou@air:~/mysrc/web/myco$ ./pcre_utf
> config_utf8=true
> [|Some ("blurb")|]
> Not_found was raised on "toxicité" :-(
> Not_found was raised on "velléités" :-(
> Not_found was raised on "à" :-(
> Not_found was raised on "où" :-(
> Not_found was raised on "über" :-(
> Not_found was raised on "marie-jeanne" :-(
> --
>
> A php user which happen to be a nice guy got it working on PHP :-( how lame.
>
> --
> Philippe Strauss
> http://www.strauss-acoustics.ch/
>
>
>
>
>
>
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
Philippe Strauss
http://www.strauss-acoustics.ch/
prev parent reply other threads:[~2012-02-16 10:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 9:29 Philippe Strauss
2012-02-16 10:18 ` Mauricio Fernandez
2012-02-16 10:18 ` Philippe Strauss [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25EC3048-818F-49DA-9721-86C83BE7E18F@strauss-acoustics.ch \
--to=philippe@strauss-acoustics.ch \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox