It can also be written like this producing smaller code. But it the cost of slower decoding.
dchar myFront(ref char[] str) pure { dchar c = cast(dchar) str.ptr[0]; if (c & 128) { if (c & 64) { int idx = 0; int l = charWidthTab.ptr[c - 192]; if (str.length < l) goto Linvalid; c = 0; l--; while(l) { l--; c |= str.ptr[idx++]; c <<= 6; } c |= str.ptr[idx]; } else Linvalid : throw new Exception("yadayada"); } return c; }