On 31 Oct 2012, at 22:15, Ken Thomases <k...@codeweavers.com> wrote:

> On Oct 31, 2012, at 9:41 AM, Gerriet M. Denkmann wrote:
> 
>> I print strings like:
>>      NSString *s = @"ร่วมรส";
>>      fprintf(stderr, "%s\n", [ s UTF8String]);
>> and usually it just works.
>> 
>> But sometimes it does not and I get garbage like:
>> ร่ว\340\270\241รส
>> 
>> Converting these numbers to hex one gets: 0xe0 0xb8 0xa1 which is the 
>> Utf8-code for THAI CHARACTER MO MA.
>> So why does it not print (as it should):
>> ร่วมรส ?
>> 
>> This is not really reproducible, but happens in about 3% of all lines.
>> 
>> Known error, or my mistake?
> 
> I have a couple of guesses:
> 
> * A bug in Terminal.app.  Does it happen in other terminal apps like iTerm 
> (if you've tried)?
No, have not. Not even used Terminal.
The stuff appears in one of the many panes of Xcode.

>  I assume it is never the case that the octal escape sequences get written 
> out to file, if you redirect stderr.  Is that correct?  (That is, I don't 
> think your program is actually writing out the octal sequence.  I think it's 
> just a display issue.)
I don't do anything at all with stderr. Maybe Xcode does.

Another thing: same problem happens (occasionally) with NSLog() also in this 
Xcode output-pane.

Printing about 5000 chars (= 15000 Utf-8 bytes) there are 8 such glitches. 
If somebody cuts my output into 1024 byte chunks, there will be 15 of these. If 
there is a 2 in 3 chance of getting the border just wrong (cutting a 3-byte 
Utf-char into 2 invalid parts) there will be 10 glitches.
Fits with the actual number of 8.

Guess your explanation sounds rather probable.

Kind regards,

Gerriet.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to