#include "internal.h" /* returns 1 if string of length n is long enough to be decoded */ int utf8·canfit(byte* s, int n) { int i; rune c; if(n <= 0) return 0; c = *(ubyte*) s; if(c < Tx) return 1; for(i = 3; i < UTFmax + 1; i++){ if(c < Tbyte(i)) return n >= i - 1; } return n >= UTFmax; }