[api] avoid a crash on non UTF-8 files