recognizing asciiz, utf ...
snake.scaly at gmail.com
Sat Mar 14 16:25:16 PDT 2009
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
> dont 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
More information about the Digitalmars-d-learn