SMB directory listing looks like normal directory listing.
[elinks.git] / Unicode / tr7bit.awk
blobe6c2621712fa3ffa6ee4559c06853fdf9326c0f3
1 #!/bin/awk -f
3 function join(array, start, sep, end, result, i)
5 if (sep == "")
6 sep = " "
7 else if (sep == SUBSEP) # magic value
8 sep = ""
9 result = array[start]
10 for (i = start + 1; i <= end; i++)
11 result = result sep array[i]
12 return result
15 function hex2dec(xx) {
16 nn = 0;
17 while (xx != "") {
18 aa = substr(xx, 1, 1);
19 ii = index("0123456789ABCDEF", aa);
20 if (!ii) ii = index("0123456789abcdef", aa);
21 if (!ii) return -1;
22 nn = nn * 16 + ii - 1;
23 xx = substr(xx, 2);
25 return nn;
28 /^U/{
29 gsub("\\\\", "\\\\");
30 split(substr($0, 3), z, ":")
31 printf("0x%08x:%s\n", hex2dec(z[1]), join(z, 2, ":"));
33 /^0x[0-9a-fA-F]*[ ]/{
34 c = hex2dec(substr($1, 3));
35 for (i = 2; i <= NF; i++) {
36 if (substr($i, 1, 1) == "#") break;
37 if (p = index($i, "-")) {
38 p1 = hex2dec(substr($i, 3, p - 3));
39 p2 = hex2dec(substr($i, p + 3));
40 } else {
41 p1 = hex2dec(substr($i, 3));
42 p2 = p1;
44 for (p = p1; p <= p2; p++) printf("0x%08x:%c\n", p, c);
47 BEGIN{
48 printf("0x000000a0:\\001\n0x000000ad:\n");