Downloading File
Filename: $strcc2html
; ; $strcc2html / String control codes to HTML ; by Spoofing <[email protected]> @ RusNet IRC Network ; ; Using: $strcc2html(string[,char])[.rawmsg] ; string - string for convert to HTML ; char = ASCII number (1-255) for replacing space ($chr(32)) into <char>, default is 10 ($chr(10) / $lf / LF) ; ; .rawmsg - If you using it for $rawmsg for save spaces :) ; * Example: on *:TEXT:*:#:write log.html $+(<,$nick,>) $strcc2html($rawmsg).rawmsg <br> ; ; Replaces: ; "&" to "&" ; "<" to "<" ; ">" to ">" ; ; Features: ; Multiple spaces. ; * Example: " " (5 spaces) to " " (3 spaces and 2 ) ; ; Greets: ; Thanks to jaytea for idea about $lf instead $chr(160). http://trout.snt.utwente.nl/ubbthreads/ubbthreads.php?ubb=showflat&Board=5&Number=227154 alias strcc2html { bset -t &stdin 1 $replacex($1,$chr(32),$iif($2,$chr($v1),$lf),&,&,<,<,>,>) $+ $chr(15) breplace &stdin $iif($2,$v1,10) 32 if ($prop == rawmsg) bcopy -c &stdin 1 &stdin $calc($bfind(&stdin,0,32 58) + 2) -1 if ($bvar(&stdin,0)) { var %i = 1, %0 = $v1, %^B = $false, %^K = $false, %^R = $false, %^I = $false, %^U = $false, %nbsp = 0 while (%i <= %0) { var %char = $bvar(&stdin,%i), %i = %i + 1 if (%char == 2) { var %^B = $iif(%^B,$false,$true) bset -t &stdout $calc($bvar(&stdout,0) + 1) $iif(%^B,<b>,</b>) } elseif (%char == 3) { var %text, %style if (%^K) { var %^K = $false bset -t &stdout $calc($bvar(&stdout,0) + 1) </span> } if ($bvar(&stdin,%i) isnum 48-57) var %text = $base($chr($v1),10,10,2), %i = %i + 1 if ($bvar(&stdin,%i) isnum 48-57) var %text = $base($+(%text,$chr($v1)),10,10,2), %i = %i + 1 if ($bvar(&stdin,%i) == 44) { var %i = %i + 1, %background if ($bvar(&stdin,%i) isnum 48-57) var %background = $base($chr($v1),10,10,2), %i = %i + 1 if ($bvar(&stdin,%i) isnum 48-57) var %background = $base($+(%background,$chr($v1)),10,10,2), %i = %i + 1 } if (%text) var %color = $base($color($v1),10,16,6), %style = $+(color:#,$mid(%color,5,2),$mid(%color,3,2),$mid(%color,1,2)) if (%background) var %background-color = $base($color($v1),10,16,6), %style = $+(%style,;background-color:#,$mid(%background-color,5,2),$mid(%background-color,3,2),$mid(%background-color,1,2)) if (%style) { var %^K = $true bset -t &stdout $calc($bvar(&stdout,0) + 1) <span style=" $+ %style $+ "> } } elseif (%char == 15) { if (%^B) { var %^B = $false bset -t &stdout $calc($bvar(&stdout,0) + 1) </b> } if (%^K) { var %^K = $false, %background bset -t &stdout $calc($bvar(&stdout,0) + 1) </span> } if (%^R) { var %^R = $false bset -t &stdout $calc($bvar(&stdout,0) + 1) </span> } if (%^I) { var %^I = $false bset -t &stdout $calc($bvar(&stdout,0) + 1) </i> } if (%^U) { var %^U = $false bset -t &stdout $calc($bvar(&stdout,0) + 1) </u> } } elseif (%char == 22) { var %text = $base($color($color(Background)),10,16,6), %background = $base($color($color(Normal text)),10,16,6), %^R = $iif(%^R,$false,$true) bset -t &stdout $calc($bvar(&stdout,0) + 1) $iif(%^R,<span style="color:# $+ $+($mid(%text,5,2),$mid(%text,3,2),$mid(%text,1,2)) $+ ;background-color:# $+ $+($mid(%background,5,2),$mid(%background,3,2),$mid(%background,1,2)) $+ ">,</span>) } elseif (%char == 29) { var %^I = $iif(%^I,$false,$true) bset -t &stdout $calc($bvar(&stdout,0) + 1) $iif(%^I,<i>,</i>) } elseif (%char == 31) { var %^U = $iif(%^U,$false,$true) bset -t &stdout $calc($bvar(&stdout,0) + 1) $iif(%^U,<u>,</u>) } elseif (%char == 32) { var %nbsp = %nbsp + 1 if (2 \\ %nbsp) { bset &stdout $calc($bvar(&stdout,0) + 1) 32 } else { bset -t &stdout $calc($bvar(&stdout,0) + 1) } } else { var %nbsp = 0 bset &stdout $calc($bvar(&stdout,0) + 1) %char } } return $bvar(&stdout,1-).text } }