Unicode
iutf8=: ((2&~:@[ #.@;;.1 <@}."_1)~ >:@i.&0"1)@((8#2)&#:@i.~&a.) utf8=: 4: u: iutf8
Converts utf8 encoded string into list of intgers (iutf8) or J unicode string (utf8)
Spreadsheets
Clipboard data
Spreadsheets programs, such as Microsoft Excel and spreadsheet application from GoogleDocs suite, put rectangular selection in a text format in the following form: displayed contents of a cells in each row are separated with a tab characer and rows are separated with "end of line" character.
ALP=:(a.{~(a.i.'A')+i.26)
NB. read tabular data from clipboard as array of boxed strings
tabget=:([: <;._2 ,&TAB);._2@wdclipread
NB. read tabular data from clipboard as array of numbers (non-complex)
tabnget=:_&".@>@tabget
NB. formats J data in tabular form acceptable by spreadsheets
tabfmt=:3 : 0
if. 0=L. y. do. y.=.<"0 y. end.
'_-' rplc~ >([ , LF"_ , ])each/([ , TAB"_ , ])&": each/"1 y.
)
tabput=:wdclipwrite@tabfmt
Column numbering
For historical reasons spreadsheet programs adopted unusual way to numbering columns. First column is labaled "A", second -- "B", etc. up to 26-th "Z" and follow through to 27-th "AA", 28-th "AB" and so on.
NB.*clfn v column lable from column number. "A" is 1
clfn=:ALP&$: : ([ {~ #@[ (4 : 0) ])
n=.x ([ <.@^. 1+*-]) y
(n#x)#:y-+/x^i.n
)
NB.*nfcl v column number from column label. "A" is 1
nfcl=:ALP&$: : (#@[ (+/@(^ i.&#) + #.) i.)"1