Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

when I use the write program to send messages, how can I use UTF-8 chars?

I send:

write user2
Ehilà! Com'è?

But receiver gets:

Message from user1@samehost on pts/1 at 21:08 ...
EhilM-CM- ! Com'M-CM-(?

The machine is the same and LANG in konsole is already en_US.UTF-8.

share|improve this question
    
Whose Konsole? Yours? The other user's? Both? –  Mikel May 31 '12 at 19:53
add comment

1 Answer

It appears write is interpreting the high bit as ‘meta-’ (Meta+key or Esc key). A quick look at the source code (function wr_fputs() in write.c) confirms this: control characters are shown as ^X, characters with the high bit set are shown as M-X. Locale settings, terminals and encodings have nothing to do with it, I'm afraid. write is just 7-bit.

Now, I'm a Unicode freak, but this makes a perverted sort of sense. write just opens the target TTY and writes to it (there's no magic involved). There's no easy way to get the character encoding understood by the process controlling the remote TTY. And even if there were, not all encodings are convertible to all other encodings. And without conversion, transmitting a message in KOI8-R to an ISO-8859-1 console would fail miserably. Since write takes the simplistic, 70s approach, this is what we get.

share|improve this answer
    
Wow. Just wow. So much for 8-bit clean. –  Mikel May 31 '12 at 21:09
    
I know. Though there are a few mitigating circumstances (I added them to the answer... too long for a comment) –  Alexios May 31 '12 at 21:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.