[OpenSCAD] How to detect chr(0)

nop head nop.head at gmail.com
Sat Apr 18 07:46:04 EDT 2015


If you just want a string of numbers, why not just use a vector? It won't
be 8 bits, it will be integers stored as floats, but as you can see
characters aren't really 8 bits either.

The only difference I can see would be if you do maths on the values but if
do it all modulo 256 with the % operator and floor divisions, etc, you
should be able to emulate 8 bits.

On 18 April 2015 at 04:26, Fantome <paul at brownsbrain.com> wrote:

> 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.
>
> _______________________________________________
> 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/20150418/8aedb18d/attachment-0002.html>


More information about the Discuss mailing list