Safely getting index from characters encoded with 3+ bytes in UTF8