using c++ detect utf8 (compute string length) and implement substr for utf8