• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /usr/bin/perl -w
2
3#
4# Copyright (C) 2017 and later: Unicode, Inc. and others.
5# License & terms of use: http://www.unicode.org/copyright.html
6#
7
8use strict;
9use IO::File;
10
11
12my $locale = $ARGV[0];
13
14
15my $long_name = `/home/weiv/src/icu/source/extra/colprobe/longname $locale`;
16print "Long name is $long_name\n";
17my $pageTitle = $locale." collation";
18my $filename = $locale.".html";
19
20open TABLE, ">$filename";
21
22
23print TABLE <<"EndOfTemplate";
24<html>
25
26<head>
27<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
28<title>$pageTitle</title>
29<style>
30         <!--
31         table        { border-spacing: 0; border-collapse: collapse; width: 100%;
32               border: 1px solid black }
33td, th       { width: 10%; border-spacing: 0; border-collapse: collapse; color: black;
34               vertical-align: top; border: 1px solid black }
35-->
36     </style>
37</head>
38
39<body bgcolor="#FFFFFF">
40
41<p><b><font color="#FF0000">Collation:</font> $locale ($long_name) <a href="http://oss.software.ibm.com/cgi-bin/icu/lx/en/?_=$locale">Demo</a>,
42
43<a href="../../comparison_charts.html">Cover
44Page</a>, <a href="../main/index.html">Locale Diffs Index</a>, <a href="index.html">Collation Diffs Index</a></b></p>
45<table>
46  <tr>
47EndOfTemplate
48
49my $dirCommon = "icucollations";
50my $refCommon = $dirCommon."/UCARules.txt";
51my $nameCommon = $dirCommon."/".$locale."_collation.html";
52my $colorCommon = "#AD989D";
53
54my $loc = $locale;
55
56if(!(-e $nameCommon)) {
57  $locale =~ /_/;
58  $loc = $`;
59  $nameCommon = "$dirCommon/$loc"."_collation.html";
60}
61
62print "Common is $nameCommon\n";
63
64print TABLE "    <th bgcolor=\"$colorCommon\">COMMON (";
65if(-e $nameCommon) {
66  print TABLE "<a href=\"../../common/collation/$loc.xml\">xml</a> ";
67}
68print TABLE "<a href=\"../../common/collation/root.xml\">UCA</a>)</th>\n";
69
70my $dirLinux = "linuxcollations";
71my $refLinux = $dirLinux."/".$locale.".utf8_default_raw.html";
72my $rawLinux = $dirLinux."/".$locale.".utf8_raw.html";
73my $defLinux = $dirLinux."/".$locale;
74my $nameLinux = "$dirLinux/$locale"."_collation.html";
75my $colorLinux = "#1191F1";
76
77print TABLE "    <th bgcolor=\"$colorLinux\">LINUX";
78if (!(-e $nameLinux)) {
79#try the variant that has @euro stuck in
80  $nameLinux = "$dirLinux/$locale".'.utf8@euro_collation.html';
81  if(-e $nameLinux) {
82    $refLinux = $dirLinux."/".$locale.'.utf8@euro_default_raw.html';
83    $rawLinux = $dirLinux."/".$locale.'.utf8@euro_raw.html';
84  }
85}
86if (-e $nameLinux) {
87  print TABLE " (<a href=\"../../linux/collation/$locale.xml\">xml</a>";
88  my $linuxBase = &getBaseLocale("$dirLinux/base", $locale);
89  if($linuxBase ne "") {
90    print TABLE " <a href=\"../../linux/collation/$linuxBase.xml\">Base ($linuxBase)</a>";
91  }
92  print TABLE ")";
93}
94print TABLE "</th>\n";
95
96
97my $dirWin = "w2kcollations";
98my $refWin = $dirWin."/".$locale."_default_raw.html";
99my $rawWin = $dirWin."/".$locale."_raw.html";
100my $nameWin = "$dirWin/$locale"."_collation.html";
101my $colorWin = "#98FB98";
102$loc = $locale;
103#try fallback for windows
104print TABLE "    <th bgcolor=\"$colorWin\">WINDOWS";
105if(!(-e $nameWin)) {
106  $locale =~ /_/;
107  $loc = $`;
108  $nameWin = "$dirWin/$loc"."_collation.html";
109}
110
111print "Windows loc is $loc\n";
112
113if (-e $nameWin) {
114  print TABLE " (<a href=\"../../windows/collation/$loc.xml\">xml</a>";
115  my $winBase = &getBaseLocale("$dirWin/base", $locale);
116  if($winBase ne "") {
117    print TABLE "<a href=\"../../windows/collation/$winBase.xml\">base ($winBase)</a>";
118  }
119  print TABLE ")";
120}
121print TABLE "</th>\n";
122print TABLE "  </tr>\n  <tr>";
123
124
125readRules($nameCommon, "#AD989D", "Same as the UCA.");
126readRules($nameLinux, "#1191F1", "No data available.");
127readRules($nameWin, "#98FB98", "No data available.");
128
129
130print TABLE <<"EndOfFooter";
131  </tr>
132</table>
133
134</body>
135</html>
136EndOfFooter
137
138
139sub readRules {
140  # readRules($file, $color)
141  my $filename  = shift;
142  my $color = shift;
143  my $comment = shift;
144  my $noLines = 0;
145  my $printOut = 0;
146
147  my $file;
148
149  if(-e $filename) {
150    open($file, "<$filename") || die "something very strange happened\n";
151    print TABLE "<td bgcolor=\"$color\">\n";
152    while (<$file>) {
153      if (/\}\<br\>$/) {
154        $printOut = 0;
155
156      }
157      if ($printOut) {
158        if(!/^$/ && !/&nbsp;<br>$/) {
159          print TABLE $_;
160          $noLines++;
161        }
162      }
163      if (/Sequence/) {
164        $printOut = 1;
165        print "found sequence\n";
166        $noLines = 0;
167      }
168
169    }
170    if (!$noLines) {
171      print TABLE "Same ordering as base\n";
172    }
173    print TABLE "</td>\n";
174  } else {
175    print TABLE "<td bgcolor=\"$color\">\n$comment</td>\n";
176  }
177}
178
179sub getBaseLocale(){
180    my $basefile = shift;
181    my $locale = shift;
182    my $baseFH = IO::File->new($basefile,"r")
183            or die  "could not open the file $basefile for reading: $! \n";
184    my $bse;
185    my $loc;
186    while(defined ( my $line = <$baseFH>)){
187        if( $line =~ /\<$locale\>/){
188            ($loc,$bse) = split (/\>/, $line);
189             $bse =~ s/^\s+\<//;
190             return $bse;
191        }
192    }
193}
194
195
196# Tasting of food product
197# 650-574-4551 $50 1 hour
198
199
200#     <td bgcolor="#AD989D">1.0-alpha</td>
201#     <td bgcolor="#FF6633">1.0</td>
202#     <td bgcolor="#FF6633">=</td>
203#     <td bgcolor="#FF6633"><span title="006E {LATIN SMALL LETTER N}">&amp;n</span><br>
204#       <span title="006E 0079 {LATIN SMALL LETTER N} {LATIN SMALL LETTER Y}">&nbsp;&nbsp;&lt;&nbsp;ny</span><br>
205
206#       <span title="006E 006E 0079 {LATIN SMALL LETTER N} {LATIN SMALL LETTER N} {LATIN SMALL LETTER Y} / 006E 0079 {LATIN SMALL LETTER N} {LATIN SMALL LETTER Y}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;nny&nbsp;/&nbsp;ny</span><br>
207#       <span title="006E 0059 {LATIN SMALL LETTER N} {LATIN CAPITAL LETTER Y}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&lt;&nbsp;nY</span><br>
208#     </td>
209#     <td bgcolor="#FF6633">=</td>
210#     <td bgcolor="#FFFF33">1.2</td>
211
212#     <td bgcolor="#98FB98">Windows XP</td>
213#     <td bgcolor="#FF6633">=</td>
214#     <td bgcolor="#FF6633">=</td>
215