recognizing asciiz, utf ...

newbee newbee at newbee.com
Sun Mar 15 02:20:08 PDT 2009


Sergey Gromov Wrote:

> Fri, 13 Mar 2009 15:04:12 -0400, newbee wrote:
> 
> > How does one check for asciiz, utf ...? 
> > I do get a buffer with characters as parameter in a function, but i
> > don�t know if it is asciiz or utf or wchar. Is it possible to find
> > out in dmd1 and dmd2? 
> 
> There is some redundancy in UTF-8 format so you can test if your string
> is a valid UTF-8 string.  There is std.utf.validate() for you.  Any
> ASCII string will also pass since ASCII is a special case of UTF-8.
> 
> Not all code points are defined in Unicode.  This means you can cast
> your string to wchar[] and then test every char using the
> std.utf.isValidDchar() function.  If it fails, then you definitely not
> dealing with a valid wchar[] string, so test dchar[] similarly.
> 
> Be prepared though that these tests will sometimes give you false
> positives.

thank you kindly. this explanation really helped me. i will try that.


More information about the Digitalmars-d-learn mailing list