List of Phobos functions that allocate memory?

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 7 21:04:08 PST 2014


On Saturday, February 08, 2014 05:29:35 Marco Leise wrote:
> I guess we just have two use cases here. One where invalid
> encoding is not an error (e.g. for sanitizing purposes) and
> one where you don't want to lose information and have to
> enforce correct encoding.
> Name the first one "decodeSubst" maybe and have decode call
> that and check for 0xFFFD?

I think that that would call for us to have 3 related but distinct functions:

1. decode, which throws on invalid Unicode. We already have this.

2. isValidUnicode, which returns whether the string is valid Unicode and does 
not throw. We don't yet have this. Rather, we have validate which does the 
same job and then throws instead of returning bool.

3. sanitizeUnicode (or whatever would be a good name for it), which replaces 
invalid Unicode with 0xFFFD (or whatever the appropriate character is) so that 
it can be operated on without causing decode to throw in spite of the fact 
that it was invalid Unicode. We don't have anything like this yet.

- Jonathan M Davis


More information about the Digitalmars-d mailing list