Latest string_token Code

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jun 22 08:44:16 PDT 2010


On 06/22/2010 08:13 AM, Ben Hanson wrote:
> Here's the latest with naming convention (hopefully) followed. I've implemented my
> own squeeze() function and used sizeof in the memmove calls.

I suggest you to look into using the range primitives (empty, front, 
back, popFront, and popBack) with strings of any width. Your code 
assumes that all characters have the same width and therefore will 
behave erratically on UTF-8 and UTF-16 encodings.

In the particular case of squeeze(), you may want to use uniq instead, 
which works on any forward range and will therefore decode characters 
properly:

http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#uniq


Andrei


More information about the Digitalmars-d mailing list