brotli_decompressor/
transform.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
#![allow(non_upper_case_globals)]

const kIdentity: u8 = 0;
const kOmitLast1: u8 = 1;
const kOmitLast2: u8 = 2;
const kOmitLast3: u8 = 3;
const kOmitLast4: u8 = 4;
const kOmitLast5: u8 = 5;
const kOmitLast6: u8 = 6;
const kOmitLast7: u8 = 7;
const kOmitLast8: u8 = 8;
const kOmitLast9: u8 = 9;
const kUppercaseFirst: u8 = 10;
const kUppercaseAll: u8 = 11;
const kOmitFirst1: u8 = 12;
const kOmitFirst2: u8 = 13;
const kOmitFirst3: u8 = 14;
const kOmitFirst4: u8 = 15;
const kOmitFirst5: u8 = 16;
const kOmitFirst6: u8 = 17;
const kOmitFirst7: u8 = 18;
// const  kOmitFirst8     : u8 = 19; // <-- unused (reserved)
const kOmitFirst9: u8 = 20;


pub struct Transform {
  pub prefix_id: u8,
  pub transform: u8,
  pub suffix_id: u8,
}

const kPrefixSuffix: [u8; 208] =
  [0x00, 0x20, 0x00, 0x2c, 0x20, 0x00, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x00, 0x20,
   0x6f, 0x66, 0x20, 0x00, 0x73, 0x20, 0x00, 0x2e, 0x00, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x00, 0x20,
   0x69, 0x6e, 0x20, 0x00, 0x22, 0x00, 0x20, 0x74, 0x6f, 0x20, 0x00, 0x22, 0x3e, 0x00, 0x0a, 0x00,
   0x2e, 0x20, 0x00, 0x5d, 0x00, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x00, 0x20, 0x61, 0x20, 0x00, 0x20,
   0x74, 0x68, 0x61, 0x74, 0x20, 0x00, 0x27, 0x00, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x00, 0x20,
   0x66, 0x72, 0x6f, 0x6d, 0x20, 0x00, 0x20, 0x62, 0x79, 0x20, 0x00, 0x28, 0x00, 0x2e, 0x20, 0x54,
   0x68, 0x65, 0x20, 0x00, 0x20, 0x6f, 0x6e, 0x20, 0x00, 0x20, 0x61, 0x73, 0x20, 0x00, 0x20, 0x69,
   0x73, 0x20, 0x00, 0x69, 0x6e, 0x67, 0x20, 0x00, 0x0a, 0x09, 0x00, 0x3a, 0x00, 0x65, 0x64, 0x20,
   0x00, 0x3d, 0x22, 0x00, 0x20, 0x61, 0x74, 0x20, 0x00, 0x6c, 0x79, 0x20, 0x00, 0x2c, 0x00, 0x3d,
   0x27, 0x00, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x00, 0x2e, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x00,
   0x20, 0x6e, 0x6f, 0x74, 0x20, 0x00, 0x65, 0x72, 0x20, 0x00, 0x61, 0x6c, 0x20, 0x00, 0x66, 0x75,
   0x6c, 0x20, 0x00, 0x69, 0x76, 0x65, 0x20, 0x00, 0x6c, 0x65, 0x73, 0x73, 0x20, 0x00, 0x65, 0x73,
   0x74, 0x20, 0x00, 0x69, 0x7a, 0x65, 0x20, 0x00, 0xc2, 0xa0, 0x00, 0x6f, 0x75, 0x73, 0x20, 0x00];
//    "\0 \0, \0 of the \0 of \0s \0.\0 and \0 in \0\"\0 to \0\">\0\n\0. \0]\0"
//    " for \0 a \0 that \0\'\0 with \0 from \0 by \0(\0. The \0 on \0 as \0"
//    " is \0ing \0\n\t\0:\0ed \0=\"\0 at \0ly \0,\0=\'\0.com/\0. This \0"
//    " not \0er \0al \0ful \0ive \0less \0est \0ize \0\xc2\xa0\0ous ";

// EMPTY = ""
// SP = " "
// DQUOT = "\""
// SQUOT = "'"
// CLOSEBR = "]"
// OPEN = "("
// SLASH = "/"
// NBSP = non-breaking space "\0xc2\xa0"
//
const kPFix_EMPTY: u8 = 0;
const kPFix_SP: u8 = 1;
const kPFix_COMMASP: u8 = 3;
const kPFix_SPofSPtheSP: u8 = 6;
const kPFix_SPtheSP: u8 = 9;
const kPFix_eSP: u8 = 12;
const kPFix_SPofSP: u8 = 15;
const kPFix_sSP: u8 = 20;
const kPFix_DOT: u8 = 23;
const kPFix_SPandSP: u8 = 25;
const kPFix_SPinSP: u8 = 31;
const kPFix_DQUOT: u8 = 36;
const kPFix_SPtoSP: u8 = 38;
const kPFix_DQUOTGT: u8 = 43;
const kPFix_NEWLINE: u8 = 46;
const kPFix_DOTSP: u8 = 48;
const kPFix_CLOSEBR: u8 = 51;
const kPFix_SPforSP: u8 = 53;
const kPFix_SPaSP: u8 = 59;
const kPFix_SPthatSP: u8 = 63;
const kPFix_SQUOT: u8 = 70;
const kPFix_SPwithSP: u8 = 72;
const kPFix_SPfromSP: u8 = 79;
const kPFix_SPbySP: u8 = 86;
const kPFix_OPEN: u8 = 91;
const kPFix_DOTSPTheSP: u8 = 93;
const kPFix_SPonSP: u8 = 100;
const kPFix_SPasSP: u8 = 105;
const kPFix_SPisSP: u8 = 110;
const kPFix_ingSP: u8 = 115;
const kPFix_NEWLINETAB: u8 = 120;
const kPFix_COLON: u8 = 123;
const kPFix_edSP: u8 = 125;
const kPFix_EQDQUOT: u8 = 129;
const kPFix_SPatSP: u8 = 132;
const kPFix_lySP: u8 = 137;
const kPFix_COMMA: u8 = 141;
const kPFix_EQSQUOT: u8 = 143;
const kPFix_DOTcomSLASH: u8 = 146;
const kPFix_DOTSPThisSP: u8 = 152;
const kPFix_SPnotSP: u8 = 160;
const kPFix_erSP: u8 = 166;
const kPFix_alSP: u8 = 170;
const kPFix_fulSP: u8 = 174;
const kPFix_iveSP: u8 = 179;
const kPFix_lessSP: u8 = 184;
const kPFix_estSP: u8 = 190;
const kPFix_izeSP: u8 = 195;
const kPFix_NBSP: u8 = 200;
const kPFix_ousSP: u8 = 203;

pub const kNumTransforms: i32 = 121;
pub const kTransforms: [Transform; kNumTransforms as usize] = [Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst1,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPtheSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_sSP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPofSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPandSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst2,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast1,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_COMMASP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_COMMASP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPinSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPtoSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_eSP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DQUOTGT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_NEWLINE,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast3,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_CLOSEBR,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPforSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst3,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast2,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPaSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPthatSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DOTSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_DOT,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_COMMASP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst4,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPwithSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPfromSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPbySP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst5,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst6,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SPtheSP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast4,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DOTSPTheSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPonSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPasSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPisSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast7,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast1,
                                                                 suffix_id: kPFix_ingSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_NEWLINETAB,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_COLON,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DOTSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_edSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst9,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitFirst7,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast6,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_OPEN,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_COMMASP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast8,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPatSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_lySP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SPtheSP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPofSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast5,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kOmitLast9,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_COMMASP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_DQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_DOT,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_OPEN,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_DQUOTGT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EQDQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_DOTcomSLASH,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SPtheSP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPofSPtheSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_SQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_DOTSPThisSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_COMMA,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_DOT,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_OPEN,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_DOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_SPnotSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EQDQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_erSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_SP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_alSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EQSQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_DQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_DOTSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_OPEN,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_fulSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_DOTSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_iveSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_lessSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_SQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_estSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_DOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_DQUOTGT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EQSQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_COMMA,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_izeSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_DOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_NBSP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_EMPTY,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_COMMA,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_EQDQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_EQDQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kIdentity,
                                                                 suffix_id: kPFix_ousSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_COMMASP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_EQSQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_COMMA,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_EQDQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_COMMASP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_COMMA,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_OPEN,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_DOTSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_DOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_EMPTY,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_EQSQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_DOTSP,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_EQDQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseAll,
                                                                 suffix_id: kPFix_EQSQUOT,
                                                               },
                                                               Transform {
                                                                 prefix_id: kPFix_SP,
                                                                 transform: kUppercaseFirst,
                                                                 suffix_id: kPFix_EQSQUOT,
                                                               }];



fn ToUpperCase(p: &mut [u8]) -> i32 {
  if (fast!((p)[0]) < 0xc0) {
    if (fast!((p)[0]) >= b'a' && fast!((p)[0]) <= b'z') {
      fast_mut!((p)[0]) ^= 32;
    }
    return 1;
  }
  // An overly simplified uppercasing model for utf-8.
  if (fast!((p)[0]) < 0xe0) {
    fast_mut!((p)[1]) ^= 32;
    return 2;
  }
  // An arbitrary transform for three byte characters.
  fast_mut!((p)[2]) ^= 5;
  3
}

pub fn TransformDictionaryWord(dst: &mut [u8],
                               mut word: &[u8],
                               mut len: i32,
                               transform: i32)
                               -> i32 {
  let mut idx: i32 = 0;
  {
    let prefix =
      &fast!((kPrefixSuffix)[fast_inner!((kTransforms)[transform as usize]).prefix_id as usize;]);
    while (fast!((prefix)[idx as usize]) != 0) {
      fast_mut!((dst)[idx as usize]) = fast!((prefix)[idx as usize]);
      idx += 1;
    }
  }
  {
    let t = fast_ref!((kTransforms)[transform as usize]).transform;
    let mut skip: i32 = if t < kOmitFirst1 {
      0
    } else {
      t as i32 - (kOmitFirst1 - 1) as i32
    };
    let mut i: i32 = 0;
    if (skip > len) {
      skip = len;
    }
    word = fast!((word)[skip as usize;]);
    len -= skip;
    if (t <= kOmitLast9) {
      len -= t as i32;
    }
    while (i < len) {
      fast_mut!((dst)[idx as usize]) = fast!((word)[i as usize]);
      idx += 1;
      i += 1;
    }
    let uppercase = &mut fast_mut!((dst)[(idx - len) as usize ;]);
    if (t == kUppercaseFirst) {
      ToUpperCase(uppercase);
    } else if (t == kUppercaseAll) {
      let mut uppercase_offset: usize = 0;
      while (len > 0) {
        let step = ToUpperCase(&mut fast_mut!((uppercase)[uppercase_offset;]));
        uppercase_offset += step as usize;
        len -= step;
      }
    }
  }
  {
    let suffix =
      &fast!((kPrefixSuffix)[fast_inner!((kTransforms)[transform as usize]).suffix_id as usize ; ]);
    let mut i: usize = 0;
    while (fast!((suffix)[i as usize]) != 0) {
      fast_mut!((dst)[idx as usize]) = fast!((suffix)[i]);
      idx += 1;
      i += 1;
    }
    idx
  }
}