- fwrite(outputbuffer,wrap_margin,1,stdout);
+ int i = wrap_margin;
+ if (target_charset == NULL) {
+ /* NULL target_charest means UTF-8 */
+ /* go back to start of nearest utf-8 character */
+ while(i>0 && (outputbuffer[i] & 0xC0) == 0x80) i--;
+ }
+ fwrite(outputbuffer,i,1,stdout);
+