delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/02/06/19:31:59

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.2 required=5.0 tests=AWL,BAYES_40,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SARE_SUB_ENC_UTF8
X-Spam-Check-By: sourceware.org
From: Bengt Larsson <lists DOT cygwin2 AT bengtl DOT net>
To: cygwin AT cygwin DOT com
Subject: A bug with UTF-8 output in a console
Date: Mon, 07 Feb 2011 01:31:45 +0100
Message-ID: <dmeuk6pajm3iupf5advanl97duk03e8rfs@4ax.com>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

----=_hbfuk6lufh19t8k06j49n5ic2no9i43qi3.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I think I have found a bug with UTF-8 output in a console in a UTF-8
locale ("C.UTF-8"). If an UTF-8 character straddles a write() boundary,
then the output gets garbled. 

An example program is attached.

----=_hbfuk6lufh19t8k06j49n5ic2no9i43qi3.MFSBCHJLHS
Content-Type: application/octet-stream; name=buftest.c
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=buftest.c

I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQKbWFpbihpbnQgYXJnYywgY2hhciAq
YXJndltdKQp7CglpbnQgaSwgYnVmOwoJCglpZiAoYXJnYyA+IDEpIHsKCQli
dWYgPSBhdG9pKGFyZ3ZbMV0pOwoJCWlmIChidWYgPD0gMCkgcmV0dXJuIDA7
Cgl9IGVsc2UgewoJCWJ1ZiA9IDU7Cgl9CgkKCXByaW50ZigiRmlyc3QgYSBz
ZXF1ZW5jZSBvZiBjaGFyYWN0ZXJzLCBhLXJpbmcsIGEtZGlhcmFlc2lzLCBv
LWRpYXJhZXNpcywgcmVwZWF0ZWQ6XG5cbiIpOwoJCglmb3IgKGk9MDsgaTwy
NTsgaSsrKQoJCXByaW50ZigiXHhjM1x4YTVceGMzXHhhNFx4YzNceGI2Iik7
CgoJcHJpbnRmKCJcblxuIik7CgkKCXByaW50ZigiTm93IHRoZSBzYW1lIHRo
aW5nIHdpdGggYSBidWZmZXIgb2YgJWQ6XG5cbiIsIGJ1Zik7CgkKCXNldHZi
dWYoc3Rkb3V0LCBOVUxMLCBfSU9GQkYsIGJ1Zik7CgkKCWZvciAoaT0wOyBp
PDI1OyBpKyspCgkJcHJpbnRmKCJceGMzXHhhNVx4YzNceGE0XHhjM1x4YjYi
KTsKCglwcmludGYoIlxuIik7CQoKCXJldHVybiAwOwp9Cg==


----=_hbfuk6lufh19t8k06j49n5ic2no9i43qi3.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
----=_hbfuk6lufh19t8k06j49n5ic2no9i43qi3.MFSBCHJLHS--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019