[OpenSCAD] How to detect chr(0)

doug moen doug at moens.org
Fri Apr 17 14:04:47 EDT 2015


The reason you see ASCII values is that ASCII is a proper subset of
unicode. The letter 'A' has value 65 in ASCII and also value 65 as a
Unicode code point. But OpenSCAD is still a Unicode system, not an ASCII
system, because the entire Unicode range is supported. So there's no need
to stop at chr(255), when you also have chr(256), chr(257), and so on.

If you want to represent an array of values between 0 and 255 using a
string, you can still do that, you'll just have represent 0 in a different
way: pick a different code point. Or you could add an offset, and use the
range chr(1) to chr(256) to represent the values 0 to 255. Of course, I'm
not really sure what you're trying to do, but I hope this has helped.

On 17 April 2015 at 12:29, Fantome <paul at brownsbrain.com> wrote:

> doug.moen wrote
> > HI Fantome. In OpenSCAD, a string is an array of Unicode "code points",
> it
> > isn't an array of bytes. Each code point in a string has a value between
> 1
> > and 0x10FFFF, except that some code point values are invalid. len(string)
> > is the number of code points in the string, and str[i] is the i'th code
> > point.
> >
> > Torsten told you that internally, strings are represented in UTF-8
> format.
> > But there are no operations in OpenSCAD that allow you to access that
> > internal representation. Numbers are represented internally as floating
> > point, but you can't access the underlying bit and byte patterns in a
> > float, either.
> >
> > Your test program contains the word ASCII several times, but that's
> > misleading, you don't have access to the underlying byte representation.
>
> Hello.
> It's interesting to hear about the inner working of this. If OpenSCAD had
> the ability to let users manipulate the bits the possibilities for
> modelling
> objects and systems would be increased. Just my opinion of course.
>
> When OpenScad echos/prints the chr(value), what it prints matches with the
> ASCII chart. This is why I named the variable ASCII_value. I don't think
> it's misleading. It is the ASCII value. It works for all 255 values, value
> 0
> is the only one that is ignored by OpenSCAD.
>
> For my specific application I guess I'll just figure out a work around
> since
> it seems obvious now that OpenSCAD is treating chr(0) as a 'something' that
> is not used in any comparison. The inner workings of OpenSCAD must have
> checks for a NULL character or chr(0) that equates to 'jump to the next
> character'. Oh well. One disappointment out of 256 values, still 99.61%
> satisfaction.
>
>
>
>
> --
> View this message in context:
> http://forum.openscad.org/How-to-detect-chr-0-tp12351p12405.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150417/06cf7799/attachment-0002.html>


More information about the Discuss mailing list