aboutsummaryrefslogtreecommitdiff
path: root/lib/enca/test/simtable.c
blob: d3f3edde3777c1aae4b5d37644efeeb8471c9c8d (plain)
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
/* @(#) $Id: simtable.c,v 1.11 2003/11/17 12:27:39 yeti Exp $ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "enca.h"
/* To cheat... */
#include "internal.h"

int myargc;
char **myargv;

static void
prl(const EncaLanguageInfo *l, const char *hooks)
{
  double *m;
  size_t i, j;

  if (myargc > 1) {
    i = 1;
    while (i < myargc && strcmp(myargv[i], l->name))
      i++;
    if (i == myargc)
      return;
  }

  printf("\n==\x1b[1m%s\x1b[m==\n", l->name);
  m = enca_get_charset_similarity_matrix(l);
  for (i = 0; i < l->ncharsets; i++) {
    for (j = 0; j < l->ncharsets; j++) {
      double q = 1000.0*m[i*l->ncharsets + j];

      if (i == j)
        printf("\x1b[36m");
      else if (q > 500)
        printf("\x1b[1;31m");
      else if (q > 333)
        printf("\x1b[31m");
      else if (q > 200)
        printf("\x1b[34m");
      else if (q < 50)
        printf("\x1b[30m");
      printf("%4.0f ", q);
      printf("\x1b[m");
    }
    printf("   %s\n", l->csnames[i]);
  }
  printf("Hooks: \x1b[32m%s\x1b[m\n", hooks);
}

int
main(int argc, char *argv[])
{
  myargc = argc;
  myargv = argv;

  prl(&ENCA_LANGUAGE_BE, "macwin isokoi 855866");
  prl(&ENCA_LANGUAGE_BG, "1251mac");
  prl(&ENCA_LANGUAGE_CS, "isowin 852kam");
  prl(&ENCA_LANGUAGE_ET, "");
  prl(&ENCA_LANGUAGE_HR, "isowin");
  prl(&ENCA_LANGUAGE_HU, "isocork isowin[XXX]");
  prl(&ENCA_LANGUAGE_LT, "winbalt lat4balt iso13win[XXX]");
  prl(&ENCA_LANGUAGE_LV, "winbalt iso13win[XXX]");
  prl(&ENCA_LANGUAGE_PL, "isowin balt13");
  prl(&ENCA_LANGUAGE_RU, "macwin");
  prl(&ENCA_LANGUAGE_SK, "isowin 852kam");
  prl(&ENCA_LANGUAGE_SL, "");
  prl(&ENCA_LANGUAGE_UK, "macwin isokoi ibm1125");

  return 0;
}