diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-12 19:42:04 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-12 19:42:04 +0100 |
commit | 820f0f0f039252533133c3bd1037a73036815a45 (patch) | |
tree | 305dd3cd0416123c27701c199164fa54e822a7fb /adapter | |
parent | 5efdc54db2d2c766d7ce7c6545207ce2ce805620 (diff) | |
download | chawan-820f0f0f039252533133c3bd1037a73036815a45.tar.gz |
twtstr: import functions from gopher2html
Diffstat (limited to 'adapter')
-rw-r--r-- | adapter/gopher/gopher2html.nim | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/adapter/gopher/gopher2html.nim b/adapter/gopher/gopher2html.nim index 4821814f..cfdeab1e 100644 --- a/adapter/gopher/gopher2html.nim +++ b/adapter/gopher/gopher2html.nim @@ -5,6 +5,8 @@ import std/os import std/streams import std/strutils +import utils/twtstr + type GopherType = enum UNKNOWN = "unsupported" TEXT_FILE = "text file" @@ -38,23 +40,6 @@ func gopherType(c: char): GopherType = of 'p': PNG else: UNKNOWN -func htmlEscape(s: string): string = - result = "" - for c in s: - case c - of '<': result &= "<" - of '>': result &= ">" - of '&': result &= "&" - of '"': result &= """ - of '\'': result &= "'" - else: result &= c - -func until(s: string, c: char, starti = 0): string = - for i in starti ..< s.len: - if s[i] == c: - break - result &= s[i] - const ControlPercentEncodeSet = {char(0x00)..char(0x1F), char(0x7F)..char(0xFF)} const QueryPercentEncodeSet = (ControlPercentEncodeSet + {' ', '"', '#', '<', '>'}) const PathPercentEncodeSet = (QueryPercentEncodeSet + {'?', '`', '{', '}'}) |