Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
write: correctly handle wide characters
Do this by replacing fputc_careful() (notice that the description said it's locale-aware ‒ it very much is /not/), with a fputs_careful() which does the same thing, but if it were to output a byte in the \123 format, first it checks whether this byte starts a valid multibyte character. If it does, and that character is printable, write it verbatim. This means that echo 'foo åäö ąęćźżń bar' | write nabijaczleweli pts/4 instead of foo \303\245\303\244\303\266 \304\205\304\231\304\207\305\272\305\274\305\204 bar yields foo åäö ąęćźżń bar or, more realistically, from a message I got earlier today, Filip powiedzia\305\202 \305\274e zap\305\202aci jutro becomes Filip powiedział że zapłaci jutro Invalid/non-printable sequences get processed as before. Line reading in write must become getline() to avoid dealing with partial characters: for example on input consisting solely of ąęćźżń, where every {1} is an instance, the output would be {42}ąęć\305\272żń{84}ąęćź\305\274ń{84}ąęćźż\305\204{39} with just fixed-512 fgets() Bug-Debian: https://bugs.debian.org/826596
- Loading branch information
1 parent
4a2d7c4
commit 8a7b845
Showing
3 changed files
with
52 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters