added option to get first invalid byte which is suitable for cropping only utf-8 part of string

Sometimes it's usable to crop unicode string and leave only valid part. For example, I'm using this in my android application.

I've modified Your code and now it provides this functionality. It still WILL return non-zero when it fails and zero when it all OK, but when You specify a valid pointer as fisrt_invalid_pos, a first position of invalid byte will be written.