Challenge: write a really really small front() for UTF8

Chris Williams yoreanon-chrisw at yahoo.co.jp
Mon Mar 24 02:40:29 PDT 2014


On Monday, 24 March 2014 at 09:02:19 UTC, monarch_dodra wrote:
> On Sunday, 23 March 2014 at 21:23:18 UTC, Andrei Alexandrescu 
> wrote:
>> Here's a baseline: http://goo.gl/91vIGc. Destroy!
>>
>> Andrei
>
> Before we roll this out, could we discuss a strategy/guideline 
> in regards to detecting and handling invalid UTF sequences?
>
> Having a fast "front" is fine and all, but if it means your 
> program asserting in release (or worst, silently corrupting 
> memory) just because the client was trying to read a bad text 
> file, I'm unsure this is acceptable.

As you'll note from the assembler, asserts are compiled out of 
release builds. Though if the goal of this little project is to 
create useful code for inclusion in a library, you would want to 
switch many of the asserts in the examples into "if (x) return 
0xfffd;". (Mine needs an assert/if in the loop to check for the 
proper bit markers).


More information about the Digitalmars-d mailing list