NULL (UCS 0) characters on MacOS : Execute and Output Bugs?

A forum for issues on macOS; the UNIX and Linux forums may have relevent posts

NULL (UCS 0) characters on MacOS : Execute and Output Bugs?

Postby petermsiegel on Sat Jan 06, 2018 1:36 am

I see some odd behaviour when displaying output that has NUL (Unicode 0) characters. I don't generally want to display null characters, but this also causes problems when executing code strings with NUL characters.
I'm using the latest Dyalog release on MAC OS High Sierra.

Is it documented that displaying a line with a (⎕UCS 0), the so-called NUL, will effectively cause everything on the line from the NULL on (possibly additional characters to its left) to disappear from the output(including the newline?). Take this code, please!
Code: Select all
⍝ Set A - NULL / UNICODE 0   (Behaves anomalously)
       'Set A'  ⋄ ⎕←'2 <',(⎕UCS 0),'>' ⋄  x←'3 <',(⎕UCS 0),'>' ⋄ ⎕←x ⋄ ((⎕UCS 0)∊x)/'x contains NULs'
Set A
2 <3 <x contains NULs

⍝ Set B - UNICODE 1 (Behaves as expected)
      'Set B'  ⋄ ⎕←'2 <',(⎕UCS 1),'>' ⋄  x←'3 <',(⎕UCS 1),'>' ⋄ ⎕←x ⋄ ((⎕UCS 1)∊x)/'x contains Unicode 1 char'
Set B
2 <○>           ⍝ In the session, a red bullet appears-- not actually this  ○ character
3 <○>           ⍝ Ditto
x contains Unicode 1 char

As far as I can tell, the lines with the NUL, that is those labelled 2 and 3 in Set A, are truncated after the NUL. As we show by assigning the result to a variable (x), the Unicode 0 is there (not shown: the variable is built properly). If we use another special character, e.g. ⎕UCS 1, we see a red bullet, the EXPECTED special symbol representing an undisplayable character; see Set B.

To make matters worse, perfectly good code with NULLs in it will fail when executed via ⍎. See Set C:
Code: Select all
⍝Set C
      a←'⎕←''',(⎕UCS 1),''''        ⍝ WORKS GREAT
⎕←'○'        ⍝ Red symbol for unprintable character (not actually ○)

      a←'⎕←''',(⎕UCS 0),''''        ⍝ ANOMALOUS
                   ⍝ Empty line (nothing, not even the ⎕← appears)

Is this a BUG? A feature? Should I have paid extra to get it? I'm sure the intent was to treat NUL (Unicode 0) like the other special characters (Unicode 1 -31), replacing them with the RED BULLET. I'm guessing there's some code using C null-string conventions for OUTPUT, but it's unexpected for ⍎ EXECUTE!

Posts: 50
Joined: Thu Nov 11, 2010 11:04 pm

Return to macOS

Who is online

Users browsing this forum: No registered users and 1 guest