Matching characters written as hex codes

Macy macyg... at gmail.com
Sun Jun 1 17:40:42 UTC 2008


Hi,

I'm trying to match some characters in a file, more exactly I'm
looking for the UNICODE BOM markers (i.e. '\xFF' '\xFE'  and '\xFE'
'\xFF'  (C-like escapes in the example..)

I've tried:

bom = \xFE \xFF @{ fprintf(stderr, "\nGot BOM UTF16"); };  -> parsing
error
bom = '\xFE' '\xFF' @{ fprintf(stderr, "\nGot BOM UTF16"); };  ->
doesn't match
bom = 0xFE 0xFF @{ fprintf(stderr, "\nGot BOM UTF16"); };  -> doesn't
match

The only way I've successfully matched the two characters was like
this:

bom = 'X' 'Y' @{ fprintf(stderr, "\nGot BOM UTF16"); };

where X and Y are the required chars, placed there with a hex editor.

So,

does anybody know the way to do this properly?

Thanks!




More information about the ragel-users mailing list