"Fossies" - the Fresh Open Source Software Archive

Member "links-1.03/Unicode/tr7bit.awk" (29 Dec 2010, 719 Bytes) of archive /linux/www/links-1.03.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) (G)AWK source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "tr7bit.awk": 2.11_vs_2.12.

    1 #!/bin/awk -f
    2 function hex2dec(xx) {
    3     nn = 0;
    4     while (xx != "") {
    5         aa = substr(xx, 1, 1);
    6         ii = index("0123456789ABCDEF", aa);
    7         if (!ii) ii = index("0123456789abcdef", aa);
    8         if (!ii) return -1;
    9         nn = nn * 16 + ii - 1;
   10         xx = substr(xx, 2);
   11     }
   12     return nn;
   13 }
   14         
   15 /^U/{
   16     gsub("\\\\", "\\\\");
   17     printf("0x%s\n", substr($0, 3));
   18 }
   19 /^0x[0-9a-fA-F]*[    ]/{
   20     c = hex2dec(substr($1, 3));
   21     for (i = 2; i <= NF; i++) {
   22         if (substr($i, 1, 1) == "#") break;
   23         if (p = index($i, "-")) {
   24             p1 = hex2dec(substr($i, 3, p - 3));
   25             p2 = hex2dec(substr($i, p + 3));
   26         } else {
   27             p1 = hex2dec(substr($i, 3));
   28             p2 = p1;
   29         }
   30         for (p = p1; p <= p2; p++) printf("0x%04x:%c\n", p, c);
   31     }
   32 }
   33 BEGIN{
   34     printf("0x00a0:\\001\n0x00ad:\n");
   35 }