[OpenSCAD] How to detect chr(0)

Fantome paul at brownsbrain.com
Fri Apr 17 23:26:18 EDT 2015


MichaelAtOz wrote
> You should read the 'invalid characters' part in the Wikipedia article.
> There a a number of Unicode chars in the range 0x7F-0xFF that are invalid.
> It is just luck that they seem to work.

Hmm, I went to a better source, Unicode.org. I couldn't find anything
stating that any values are invalid but I did find this:
*Q: Are noncharacters invalid in Unicode strings and UTFs?

A: Absolutely not. Noncharacters do not cause a Unicode string to be
ill-formed in any UTF. This can be seen explicitly in the table above, where
every noncharacter code point has a well-formed representation in UTF-32, in
UTF-16, and in UTF-8. An implementation which converts noncharacter code
points between one UTF representation and another must preserve these values
correctly. The fact that they are called "noncharacters" and are not
intended for open interchange does not mean that they are somehow illegal or
invalid code points which make strings containing them invalid.
*
Maybe there is some confusion with what I am doing. I'm not looking to print
anything out as in text. I am only interested in the 8bit values. Wether
it's Unicode, ASCII or whatever doesn't really matter because 8 bits will
always be 8 bits, even if they are taken from a 32 bit value. 

I looked at the chart on Unicode.org for the values from 0x80 to 0xFF and
didn't see anything unexpected. I'll post my code this weekend. It seems
that I always have a hard time explaining my thoughts and methods. (This is
on me, nobody else.) Perhaps seeing the code will make it clear. 

In any case, my original question has been answered and I now have a way to
use chr() to represent 0x00. Thanks for that.




--
View this message in context: http://forum.openscad.org/How-to-detect-chr-0-tp12351p12415.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list