12e5b6d6dSopenharmony_ci#! /usr/bin/perl -w
22e5b6d6dSopenharmony_ci
32e5b6d6dSopenharmony_ci#
42e5b6d6dSopenharmony_ci# Copyright (C) 2017 and later: Unicode, Inc. and others.
52e5b6d6dSopenharmony_ci# License & terms of use: http://www.unicode.org/copyright.html
62e5b6d6dSopenharmony_ci#
72e5b6d6dSopenharmony_ci
82e5b6d6dSopenharmony_ciuse strict;
92e5b6d6dSopenharmony_ciuse IO::File;
102e5b6d6dSopenharmony_ci
112e5b6d6dSopenharmony_ci
122e5b6d6dSopenharmony_cimy $locale = $ARGV[0];
132e5b6d6dSopenharmony_ci
142e5b6d6dSopenharmony_ci
152e5b6d6dSopenharmony_cimy $long_name = `/home/weiv/src/icu/source/extra/colprobe/longname $locale`;
162e5b6d6dSopenharmony_ciprint "Long name is $long_name\n";
172e5b6d6dSopenharmony_cimy $pageTitle = $locale." collation";
182e5b6d6dSopenharmony_cimy $filename = $locale.".html";
192e5b6d6dSopenharmony_ci
202e5b6d6dSopenharmony_ciopen TABLE, ">$filename";
212e5b6d6dSopenharmony_ci
222e5b6d6dSopenharmony_ci
232e5b6d6dSopenharmony_ciprint TABLE <<"EndOfTemplate";
242e5b6d6dSopenharmony_ci<html>
252e5b6d6dSopenharmony_ci
262e5b6d6dSopenharmony_ci<head>
272e5b6d6dSopenharmony_ci<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
282e5b6d6dSopenharmony_ci<title>$pageTitle</title>
292e5b6d6dSopenharmony_ci<style>
302e5b6d6dSopenharmony_ci         <!--
312e5b6d6dSopenharmony_ci         table        { border-spacing: 0; border-collapse: collapse; width: 100%;
322e5b6d6dSopenharmony_ci               border: 1px solid black }
332e5b6d6dSopenharmony_citd, th       { width: 10%; border-spacing: 0; border-collapse: collapse; color: black;
342e5b6d6dSopenharmony_ci               vertical-align: top; border: 1px solid black }
352e5b6d6dSopenharmony_ci-->
362e5b6d6dSopenharmony_ci     </style>
372e5b6d6dSopenharmony_ci</head>
382e5b6d6dSopenharmony_ci
392e5b6d6dSopenharmony_ci<body bgcolor="#FFFFFF">
402e5b6d6dSopenharmony_ci
412e5b6d6dSopenharmony_ci<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>,
422e5b6d6dSopenharmony_ci
432e5b6d6dSopenharmony_ci<a href="../../comparison_charts.html">Cover
442e5b6d6dSopenharmony_ciPage</a>, <a href="../main/index.html">Locale Diffs Index</a>, <a href="index.html">Collation Diffs Index</a></b></p>
452e5b6d6dSopenharmony_ci<table>
462e5b6d6dSopenharmony_ci  <tr>
472e5b6d6dSopenharmony_ciEndOfTemplate
482e5b6d6dSopenharmony_ci
492e5b6d6dSopenharmony_cimy $dirCommon = "icucollations";
502e5b6d6dSopenharmony_cimy $refCommon = $dirCommon."/UCARules.txt";
512e5b6d6dSopenharmony_cimy $nameCommon = $dirCommon."/".$locale."_collation.html";
522e5b6d6dSopenharmony_cimy $colorCommon = "#AD989D";
532e5b6d6dSopenharmony_ci
542e5b6d6dSopenharmony_cimy $loc = $locale;
552e5b6d6dSopenharmony_ci
562e5b6d6dSopenharmony_ciif(!(-e $nameCommon)) {
572e5b6d6dSopenharmony_ci  $locale =~ /_/;
582e5b6d6dSopenharmony_ci  $loc = $`;
592e5b6d6dSopenharmony_ci  $nameCommon = "$dirCommon/$loc"."_collation.html";
602e5b6d6dSopenharmony_ci}
612e5b6d6dSopenharmony_ci
622e5b6d6dSopenharmony_ciprint "Common is $nameCommon\n";
632e5b6d6dSopenharmony_ci
642e5b6d6dSopenharmony_ciprint TABLE "    <th bgcolor=\"$colorCommon\">COMMON (";
652e5b6d6dSopenharmony_ciif(-e $nameCommon) {
662e5b6d6dSopenharmony_ci  print TABLE "<a href=\"../../common/collation/$loc.xml\">xml</a> ";
672e5b6d6dSopenharmony_ci}
682e5b6d6dSopenharmony_ciprint TABLE "<a href=\"../../common/collation/root.xml\">UCA</a>)</th>\n";
692e5b6d6dSopenharmony_ci
702e5b6d6dSopenharmony_cimy $dirLinux = "linuxcollations";
712e5b6d6dSopenharmony_cimy $refLinux = $dirLinux."/".$locale.".utf8_default_raw.html";
722e5b6d6dSopenharmony_cimy $rawLinux = $dirLinux."/".$locale.".utf8_raw.html";
732e5b6d6dSopenharmony_cimy $defLinux = $dirLinux."/".$locale;
742e5b6d6dSopenharmony_cimy $nameLinux = "$dirLinux/$locale"."_collation.html";
752e5b6d6dSopenharmony_cimy $colorLinux = "#1191F1";
762e5b6d6dSopenharmony_ci
772e5b6d6dSopenharmony_ciprint TABLE "    <th bgcolor=\"$colorLinux\">LINUX";
782e5b6d6dSopenharmony_ciif (!(-e $nameLinux)) {
792e5b6d6dSopenharmony_ci#try the variant that has @euro stuck in
802e5b6d6dSopenharmony_ci  $nameLinux = "$dirLinux/$locale".'.utf8@euro_collation.html';
812e5b6d6dSopenharmony_ci  if(-e $nameLinux) {
822e5b6d6dSopenharmony_ci    $refLinux = $dirLinux."/".$locale.'.utf8@euro_default_raw.html';
832e5b6d6dSopenharmony_ci    $rawLinux = $dirLinux."/".$locale.'.utf8@euro_raw.html';
842e5b6d6dSopenharmony_ci  }
852e5b6d6dSopenharmony_ci}
862e5b6d6dSopenharmony_ciif (-e $nameLinux) {
872e5b6d6dSopenharmony_ci  print TABLE " (<a href=\"../../linux/collation/$locale.xml\">xml</a>";
882e5b6d6dSopenharmony_ci  my $linuxBase = &getBaseLocale("$dirLinux/base", $locale);
892e5b6d6dSopenharmony_ci  if($linuxBase ne "") {
902e5b6d6dSopenharmony_ci    print TABLE " <a href=\"../../linux/collation/$linuxBase.xml\">Base ($linuxBase)</a>";
912e5b6d6dSopenharmony_ci  }
922e5b6d6dSopenharmony_ci  print TABLE ")";
932e5b6d6dSopenharmony_ci}
942e5b6d6dSopenharmony_ciprint TABLE "</th>\n";
952e5b6d6dSopenharmony_ci
962e5b6d6dSopenharmony_ci
972e5b6d6dSopenharmony_cimy $dirWin = "w2kcollations";
982e5b6d6dSopenharmony_cimy $refWin = $dirWin."/".$locale."_default_raw.html";
992e5b6d6dSopenharmony_cimy $rawWin = $dirWin."/".$locale."_raw.html";
1002e5b6d6dSopenharmony_cimy $nameWin = "$dirWin/$locale"."_collation.html";
1012e5b6d6dSopenharmony_cimy $colorWin = "#98FB98";
1022e5b6d6dSopenharmony_ci$loc = $locale;
1032e5b6d6dSopenharmony_ci#try fallback for windows
1042e5b6d6dSopenharmony_ciprint TABLE "    <th bgcolor=\"$colorWin\">WINDOWS";
1052e5b6d6dSopenharmony_ciif(!(-e $nameWin)) {
1062e5b6d6dSopenharmony_ci  $locale =~ /_/;
1072e5b6d6dSopenharmony_ci  $loc = $`;
1082e5b6d6dSopenharmony_ci  $nameWin = "$dirWin/$loc"."_collation.html";
1092e5b6d6dSopenharmony_ci}
1102e5b6d6dSopenharmony_ci
1112e5b6d6dSopenharmony_ciprint "Windows loc is $loc\n";
1122e5b6d6dSopenharmony_ci
1132e5b6d6dSopenharmony_ciif (-e $nameWin) {
1142e5b6d6dSopenharmony_ci  print TABLE " (<a href=\"../../windows/collation/$loc.xml\">xml</a>";
1152e5b6d6dSopenharmony_ci  my $winBase = &getBaseLocale("$dirWin/base", $locale);
1162e5b6d6dSopenharmony_ci  if($winBase ne "") {
1172e5b6d6dSopenharmony_ci    print TABLE "<a href=\"../../windows/collation/$winBase.xml\">base ($winBase)</a>";
1182e5b6d6dSopenharmony_ci  }
1192e5b6d6dSopenharmony_ci  print TABLE ")";
1202e5b6d6dSopenharmony_ci}
1212e5b6d6dSopenharmony_ciprint TABLE "</th>\n";
1222e5b6d6dSopenharmony_ciprint TABLE "  </tr>\n  <tr>";
1232e5b6d6dSopenharmony_ci
1242e5b6d6dSopenharmony_ci
1252e5b6d6dSopenharmony_cireadRules($nameCommon, "#AD989D", "Same as the UCA.");
1262e5b6d6dSopenharmony_cireadRules($nameLinux, "#1191F1", "No data available.");
1272e5b6d6dSopenharmony_cireadRules($nameWin, "#98FB98", "No data available.");
1282e5b6d6dSopenharmony_ci
1292e5b6d6dSopenharmony_ci
1302e5b6d6dSopenharmony_ciprint TABLE <<"EndOfFooter";
1312e5b6d6dSopenharmony_ci  </tr>
1322e5b6d6dSopenharmony_ci</table>
1332e5b6d6dSopenharmony_ci
1342e5b6d6dSopenharmony_ci</body>
1352e5b6d6dSopenharmony_ci</html>
1362e5b6d6dSopenharmony_ciEndOfFooter
1372e5b6d6dSopenharmony_ci
1382e5b6d6dSopenharmony_ci
1392e5b6d6dSopenharmony_cisub readRules {
1402e5b6d6dSopenharmony_ci  # readRules($file, $color)
1412e5b6d6dSopenharmony_ci  my $filename  = shift;
1422e5b6d6dSopenharmony_ci  my $color = shift;
1432e5b6d6dSopenharmony_ci  my $comment = shift;
1442e5b6d6dSopenharmony_ci  my $noLines = 0;
1452e5b6d6dSopenharmony_ci  my $printOut = 0;
1462e5b6d6dSopenharmony_ci
1472e5b6d6dSopenharmony_ci  my $file;
1482e5b6d6dSopenharmony_ci
1492e5b6d6dSopenharmony_ci  if(-e $filename) {
1502e5b6d6dSopenharmony_ci    open($file, "<$filename") || die "something very strange happened\n";
1512e5b6d6dSopenharmony_ci    print TABLE "<td bgcolor=\"$color\">\n";
1522e5b6d6dSopenharmony_ci    while (<$file>) {
1532e5b6d6dSopenharmony_ci      if (/\}\<br\>$/) {
1542e5b6d6dSopenharmony_ci        $printOut = 0;
1552e5b6d6dSopenharmony_ci
1562e5b6d6dSopenharmony_ci      }
1572e5b6d6dSopenharmony_ci      if ($printOut) {
1582e5b6d6dSopenharmony_ci        if(!/^$/ && !/&nbsp;<br>$/) {
1592e5b6d6dSopenharmony_ci          print TABLE $_;
1602e5b6d6dSopenharmony_ci          $noLines++;
1612e5b6d6dSopenharmony_ci        }
1622e5b6d6dSopenharmony_ci      }
1632e5b6d6dSopenharmony_ci      if (/Sequence/) {
1642e5b6d6dSopenharmony_ci        $printOut = 1;
1652e5b6d6dSopenharmony_ci        print "found sequence\n";
1662e5b6d6dSopenharmony_ci        $noLines = 0;
1672e5b6d6dSopenharmony_ci      }
1682e5b6d6dSopenharmony_ci
1692e5b6d6dSopenharmony_ci    }
1702e5b6d6dSopenharmony_ci    if (!$noLines) {
1712e5b6d6dSopenharmony_ci      print TABLE "Same ordering as base\n";
1722e5b6d6dSopenharmony_ci    }
1732e5b6d6dSopenharmony_ci    print TABLE "</td>\n";
1742e5b6d6dSopenharmony_ci  } else {
1752e5b6d6dSopenharmony_ci    print TABLE "<td bgcolor=\"$color\">\n$comment</td>\n";
1762e5b6d6dSopenharmony_ci  }
1772e5b6d6dSopenharmony_ci}
1782e5b6d6dSopenharmony_ci
1792e5b6d6dSopenharmony_cisub getBaseLocale(){
1802e5b6d6dSopenharmony_ci    my $basefile = shift;
1812e5b6d6dSopenharmony_ci    my $locale = shift;
1822e5b6d6dSopenharmony_ci    my $baseFH = IO::File->new($basefile,"r")
1832e5b6d6dSopenharmony_ci            or die  "could not open the file $basefile for reading: $! \n";
1842e5b6d6dSopenharmony_ci    my $bse;
1852e5b6d6dSopenharmony_ci    my $loc;
1862e5b6d6dSopenharmony_ci    while(defined ( my $line = <$baseFH>)){
1872e5b6d6dSopenharmony_ci        if( $line =~ /\<$locale\>/){
1882e5b6d6dSopenharmony_ci            ($loc,$bse) = split (/\>/, $line);
1892e5b6d6dSopenharmony_ci             $bse =~ s/^\s+\<//;
1902e5b6d6dSopenharmony_ci             return $bse;
1912e5b6d6dSopenharmony_ci        }
1922e5b6d6dSopenharmony_ci    }
1932e5b6d6dSopenharmony_ci}
1942e5b6d6dSopenharmony_ci
1952e5b6d6dSopenharmony_ci
1962e5b6d6dSopenharmony_ci# Tasting of food product
1972e5b6d6dSopenharmony_ci# 650-574-4551 $50 1 hour
1982e5b6d6dSopenharmony_ci
1992e5b6d6dSopenharmony_ci
2002e5b6d6dSopenharmony_ci#     <td bgcolor="#AD989D">1.0-alpha</td>
2012e5b6d6dSopenharmony_ci#     <td bgcolor="#FF6633">1.0</td>
2022e5b6d6dSopenharmony_ci#     <td bgcolor="#FF6633">=</td>
2032e5b6d6dSopenharmony_ci#     <td bgcolor="#FF6633"><span title="006E {LATIN SMALL LETTER N}">&amp;n</span><br>
2042e5b6d6dSopenharmony_ci#       <span title="006E 0079 {LATIN SMALL LETTER N} {LATIN SMALL LETTER Y}">&nbsp;&nbsp;&lt;&nbsp;ny</span><br>
2052e5b6d6dSopenharmony_ci
2062e5b6d6dSopenharmony_ci#       <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>
2072e5b6d6dSopenharmony_ci#       <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>
2082e5b6d6dSopenharmony_ci#     </td>
2092e5b6d6dSopenharmony_ci#     <td bgcolor="#FF6633">=</td>
2102e5b6d6dSopenharmony_ci#     <td bgcolor="#FFFF33">1.2</td>
2112e5b6d6dSopenharmony_ci
2122e5b6d6dSopenharmony_ci#     <td bgcolor="#98FB98">Windows XP</td>
2132e5b6d6dSopenharmony_ci#     <td bgcolor="#FF6633">=</td>
2142e5b6d6dSopenharmony_ci#     <td bgcolor="#FF6633">=</td>
215