Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

* gb notes that fdisk thinks his cdrom can store one terabyte -- Seen on #Linux


devel / comp.lang.awk / Urlencoder + Shell Alias

SubjectAuthor
* Urlencoder + Shell AliasMike Sanders
`- Re: Urlencoder + Shell AliasMike Sanders

1
Urlencoder + Shell Alias

<uii062$2382t$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1736&group=comp.lang.awk#1736

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Urlencoder + Shell Alias
Date: Thu, 9 Nov 2023 07:02:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uii062$2382t$1@dont-email.me>
Injection-Date: Thu, 9 Nov 2023 07:02:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2196fbaffb7fbbc7ba1c914477bbd53c";
logging-data="2203741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186VzrKR/kYuxXYBLDR6ALU"
Keywords: Mike's Notes
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:v21cvhtUssbqt+J3HTZWeNPt0Kw=
 by: Mike Sanders - Thu, 9 Nov 2023 07:02 UTC

Beware wordwrap.

# tags: urlencode, url, search, lynx, alias, shell, awk, code
# # awk script urlencodes output - ASCII chars only,
# doesn't deal with multibyte UTF-8 chars
# Michael Sanders 2023
# https://busybox.neocities.org/notes/urlencode.txt
# # handy shell function & alias...
# # search() {
# query=$(echo "$*" | awk -f urlencode.txt)
# lynx "https://lite.duckduckgo.com/lite/?q=$query"
# }
# # alias ?=search
# # usage example: ? what is awk

{ print urlencode($0) }

BEGIN { FS = OFS = "" }

function urlencode(str, x, y, c, encoded) {
encoded = ""
y = length(str)
for (x = 1; x <= y; x++) {
c = substr(str, x, 1)
if (c ~ /[0-9A-Za-z]/) encoded = encoded c # alphanumeric chars are not encoded
else encoded = encoded "%" hexify(c) # other chars are percent-encoded
}
return encoded
}

function hexify(c) {
hex = "0123456789ABCDEF"
asc = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
pos = index(asc, c)
if (pos == 0) return "00" # handle non-printable chars (like \n, which shouldn't appear in URL)
hib = int((pos + 31) / 16)
lob = int((pos + 31) % 16)
return substr(hex, hib + 1, 1) substr(hex, lob + 1, 1)
}

# eof

--
:wq
Mike Sanders

Re: Urlencoder + Shell Alias

<uiie6n$25ouv$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1737&group=comp.lang.awk#1737

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsfeed.xs3.de!callisto.xs3.de!gandalf.srv.welterde.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: Urlencoder + Shell Alias
Date: Thu, 9 Nov 2023 11:01:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uiie6n$25ouv$1@dont-email.me>
References: <uii062$2382t$1@dont-email.me>
Injection-Date: Thu, 9 Nov 2023 11:01:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2196fbaffb7fbbc7ba1c914477bbd53c";
logging-data="2286559"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7skoG+3R/KpiV1uYSWmU5"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:6Bt/5Vj58CqtWhiRpxrGsXMcSBE=
 by: Mike Sanders - Thu, 9 Nov 2023 11:01 UTC

Mike Sanders <porkchop@invalid.foo> wrote:

> function hexify(c) {
> hex = "0123456789ABCDEF"
> asc = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
> pos = index(asc, c)
> if (pos == 0) return "00" # handle non-printable chars (like \n, which shouldn't appear in URL)
> hib = int((pos + 31) / 16)
> lob = int((pos + 31) % 16)
> return substr(hex, hib + 1, 1) substr(hex, lob + 1, 1)
> }

Imprtant update (just reload the page):

https://busybox.neocities.org/notes/urlencode.txt

--
:wq
Mike Sanders

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor