u: 256#. inv 
9812938749123747923849273491287349128437921837928173492734791823749102983479128379128472342342342342342342342343x

will print visually useful binary data (I guess referred to as superascii here: 
 
http://www.jsoftware.com/jwiki/Guides/UnicodeGettingStarted?highlight=%28unicode%29)

  timespacex 'u: 65536#. inv 
9812938749123747923849273491287349128437921837928173492734791823749102983479128379128472342342342342342342342343x'
 
0.00072128 77184 

  timespacex 'u: 256#. inv 
9812938749123747923849273491287349128437921837928173492734791823749102983479128379128472342342342342342342342343x'
 
0.00013824 114944

quite a bit faster to just stick to superascii, but the reason for it is this 
surprising result:

 timespacex '256x#. 256#. inv 
9812938749123747923849273491287349128437921837928173492734791823749102983479128379128472342342342342342342342343x'
 
0.00016256 115200 


 timespacex '65536x#. 65536#. inv 
9812938749123747923849273491287349128437921837928173492734791823749102983479128379128472342342342342342342342343x'
 
0.00069696 77440

its surprising in that it should be less work to split and reassemble into 
larger chunks.

another quirk:
(expected)
 3!:0 u: 65536 #. inv 9812923438x 
131072

 3!:0 ": u: 65536 #. inv 9812923438x 
2  NB. string but displays the same as if unicode.  sounds neat.

  3 u: u: ": u: 65536 #. inv 9812923438x 
2 228 163 165 229 144 174 
 
if you take a string that looks like unicode it turns into superascii

 3 u:  u: 65536 #. inv 9812923438x 
2 18661 21550 


one way to ensure the right result is to use instead of uucp, 


uucp2 =:  ucp`]`(ucp@:u:)@.(1 i.~ 2 131072 = 3!:0)


 3 u: uucp2  3 u: u:   65536 #. inv 9812923438x 
2 18661 21550
 3 u: uucp2  ": u: 65536 #. inv 9812923438x 
2 18661 21550 

 3 u: uucp2   u:   65536 #. inv 9812923438x 
2 18661 21550
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to