[OpenSCAD] How to detect chr(0)

Fantome paul at brownsbrain.com
Fri Apr 17 12:29:16 EDT 2015


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.




More information about the Discuss mailing list