Differences between revisions 9 and 10
Revision 9 as of 2009-09-03 06:59:56
Size: 479
Editor: anonymous
Comment: origin independent
Revision 10 as of 2009-09-03 07:12:19
Size: 760
Editor: anonymous
Comment: problem beyond unicode 127
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
These functions have a problem in ''Dyalog Unicode'' edition for characters beyond `⎕UCS 127`; the last line of `HexToText` appears to be to squeeze out `⎕AV[0]` that appears in alternating positions of `82 ⎕DR ⍵` if such characters are included in the ''Classic'' edition.

Hex And Text

From time to time you might have to convert strings to hex or vice versa:

  • TextToHex←{
         a←83 ⎕DR ⍵
         a←⎕IO+,⍉16 16⊤a
         '0123456789ABCDEF'[a]
     }

And the other way round:

  • HexToText←{
         a←16|-⎕IO-'0123456789ABCDEF0123456789abcdef'⍳⍵
         a←{⍵⍴⍨2,⍨0.5×⍴⍵}a
         a←16⊥⍉a
         {⍵{(⍺{⍵⍴(⍵÷⍴⍺)↑1}⍴⍵)/⍵}82 ⎕DR ⍵}a
     }

These functions have a problem in Dyalog Unicode edition for characters beyond ⎕UCS 127; the last line of HexToText appears to be to squeeze out ⎕AV[0] that appears in alternating positions of 82 ⎕DR ⍵ if such characters are included in the Classic edition.


CategoryDyalog

HexAndText (last edited 2009-09-03 07:12:19 by anonymous)