intl/chardet/tools/genhz.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/chardet/tools/genhz.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +#!/usr/local/bin/perl
     1.5 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +
     1.9 +use strict;
    1.10 +require "genverifier.pm";
    1.11 +use genverifier;
    1.12 +
    1.13 +
    1.14 +my(@hz_cls);
    1.15 +my(@hz_st);
    1.16 +my($hz_ver);
    1.17 +
    1.18 +
    1.19 +#
    1.20 +#
    1.21 +# > 0x80  - 1
    1.22 +# ~       - 2
    1.23 +# LF      - 3
    1.24 +# {       - 4
    1.25 +# }       - 5
    1.26 +#
    1.27 +@hz_cls = (
    1.28 + [ 0x01 , 0x1a , 0 ],
    1.29 + [ 0x7e , 0x7e , 2 ],
    1.30 + [ 0x0a , 0x0a , 3 ],
    1.31 + [ 0x7b , 0x7b , 4 ],
    1.32 + [ 0x7d , 0x7d , 5 ],
    1.33 + [ 0x1c , 0x7f , 0 ],
    1.34 + [ 0x0e , 0x0f , 1 ],
    1.35 + [ 0x1b , 0x1b , 1 ],
    1.36 + [ 0x00 , 0x00 , 1 ],
    1.37 + [ 0x80 , 0xff , 1 ]
    1.38 +);
    1.39 +
    1.40 +
    1.41 +#
    1.42 +#
    1.43 +package genverifier;
    1.44 +@hz_st = (
    1.45 +# 0  1  2  3  4  5 
    1.46 +  0, 1, 3, 0, 0, 0, # Start State - 0
    1.47 +  1, 1, 1, 1, 1, 1, # Error State - 1
    1.48 +  2, 2, 2, 2, 2, 2, # ItsMe State - 2
    1.49 +  1, 1, 0, 0, 4, 1, # state 3 - got ~
    1.50 +  5, 1, 6, 1, 5, 5, # state 4 - got ~ {
    1.51 +  4, 1, 4, 1, 4, 4, # state 5 - got ~ { X
    1.52 +  4, 1, 4, 1, 4, 2, # state 6 - got ~ { [X X]* ~
    1.53 +);
    1.54 +
    1.55 +$hz_ver = genverifier::GenVerifier("HZ", "HZ-GB-2312", 
    1.56 +      \@hz_cls, 6, \@hz_st);
    1.57 +print $hz_ver;
    1.58 +
    1.59 +
    1.60 +

mercurial