[M3devel] AND (…, 16_ff)… Not serious - or so I hope!

Dragiša Durić dragisha at m3w.org
Tue Jun 26 12:18:41 CEST 2012


This piece of code, from TextClass.m3, disturbs me… a lot.

If we are to use WIDECHAR, I think we must be a lot more serious than this.

Probably, text pieces are limited to 128 bytes by design, somewhere. But - whose idea was to "narrow" by ignoring everything except 8 LSB's? By mapping set of 2^20 elements to set of 2^8 elements.

Probably by someone whose mother tongue is fully writeable with ASCII :).

====
PROCEDURE GetChars (t: TEXT;  VAR a: ARRAY OF CHAR;  start: CARDINAL) =
 VAR
   info : Info;
   cnt  : INTEGER;
   next : CARDINAL := 0;
   buf  : ARRAY [0..127] OF WIDECHAR;
 BEGIN
   t.get_info (info);
   cnt := MIN (NUMBER (a), info.length - start);
   WHILE (cnt > 0) DO
     t.get_wide_chars (buf, start);
     FOR i := FIRST (buf) TO LAST (buf) DO
       IF (cnt = 0) THEN RETURN END;
       a[next] := VAL (Word.And (ORD (buf[i]), 16_ff), CHAR);
       INC (next);  DEC (cnt);
     END;
     INC (start, NUMBER (buf));
   END;
 END GetChars;
====




More information about the M3devel mailing list