# HG changeset patch # User Matti Hamalainen # Date 1483926953 -7200 # Node ID 124b97f5a19dce982fb457dd6d1c88b79bc64317 # Parent 5763716060a05ed9dd256f269ec8cbaf8f8c510a utillib: Add some comments, bump copyright. diff -r 5763716060a0 -r 124b97f5a19d utillib.tcl --- a/utillib.tcl Sun Jan 08 05:09:50 2017 +0200 +++ b/utillib.tcl Mon Jan 09 03:55:53 2017 +0200 @@ -1,7 +1,7 @@ ########################################################################## # # TCL functions library by Matti 'ccr' Hamalainen -# (C) Copyright 2015 Tecnic Software productions (TNSP) +# (C) Copyright 2015-2017 Tecnic Software productions (TNSP) # # This script is freely distributable under GNU GPL (version 2) license. # @@ -20,12 +20,16 @@ set utl_html_ent_list [split [encoding convertfrom "utf-8" $utl_html_ent_str] "|"] +# Convert given string, containing HTML/XML style entities into a normal +# UTF-8 Unicode string, using the above entity->character mapping proc utl_convert_html_ent {udata} { global utl_html_ent_list return [string map -nocase $utl_html_ent_list [string map $utl_html_ent_list $udata]] } +# Split given string "str" into a list of sub-strings of maximum length +# "maxlen", by attempting to split at "words", if possible. proc utl_str_split {str maxlen} { set pos 0 set len [string length $str] @@ -63,6 +67,8 @@ } +# Send IRC message with given message type, splitting the +# string to fit to IRCNet (etc.) max message length. proc utl_msg_do {upreferredmsg upublic unick uchan umsg} { foreach uline [utl_str_split $umsg 450] { if {$upublic == 1} { @@ -74,6 +80,7 @@ } +# Return formatted time for given UNIX timestamp proc utl_ctime {utime} { if {$utime == "" || $utime == "*"} { set utime 0