https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66499
--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- The trimmed length is incorrect. With this test: program test_character real:: a character(len=2, kind=4):: char1, char2 char2 = 4_"Ã" open(6, encoding="utf-8") write(*,'(a)') trim(char2) !print *, len(trim(char2),4) end program The length computed for len(trim(char2),4) is 2. $ ./a.out >test.out [jerry@amda8 pr66499]$ xxd test.out 00000000: c383 c283 0a We have an extra word being emitted. Two extra bytes.