• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hex representation of NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hex representation of NSString


  • Subject: Re: Hex representation of NSString
  • From: "Clark Cox" <email@hidden>
  • Date: Mon, 18 Aug 2008 08:38:10 -0700

On Mon, Aug 18, 2008 at 7:38 AM, Jason Coco <email@hidden> wrote:
>
> On Aug 18, 2008, at 10:18 , Clark Cox wrote:
>
>> On Mon, Aug 18, 2008 at 5:38 AM, Jason Coco <email@hidden> wrote:
>>>
>>> On Aug 18, 2008, at 07:18 , Robert Černý wrote:
>>>
>>>> Actually,I'm trying to debug some weird problems with clipboard. My
>>>> problem
>>>> is that data copied into clipboard from legacy java application doesn't
>>>> match data pasted into Cocoa application. I've got data with accented
>>>> characters which gets converted through MacOS Roman encoding even the
>>>> visual
>>>> representation in java is correct.
>>>
>>>
>>> If you want to print the string as hexadecimal without any conversions,
>>> you
>>> can do
>>> something like the following (keep in mind this is showing you basically
>>> the
>>> UCS-2 version of the string):
>>
>> Not UCS-2, UTF-16. (The distinction is important if the string
>> contains any characters outside of the BMP.
>
> Yeah, my bad... UTF-16, not UCS-2
>
>>> void dumpString(NSString *str)
>>> {
>>>      NSUInteger len = [str length];
>>>      unichar *chars = malloc(len * sizeof(unichar));
>>>      [str getCharacters:chars];
>>>      uint i;
>>
>> i should be NSUInteger as well.
>
> I don't think that really matters all that much, just a matter of
> style mostly. I think /should/ is strong. It could be NSUInteger
> or just int or uint32_t or unsigned int or whatever...

If the length is an NSUInteger, then the counter should be as well.

> it's just  a counter for a simple debugging example, right :)

Indeed, but unless there's a good reason, using different types for
the index and the limit is not a good idea.

>
>>>      printf("NSString at p = { ", str);
>>
>> No need to use p, just use %p.
>
> I wanted p... it was on purpose. I like my debugging messages
> to line up properly :)

Then what happens when you build 64-bit? :)

--
Clark S. Cox III
email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Hex representation of NSString
      • From: Jason Coco <email@hidden>
References: 
 >Hex representation of NSString (From: "Robert Černý" <email@hidden>)
 >Re: Hex representation of NSString (From: Negm-Awad Amin <email@hidden>)
 >Re: Hex representation of NSString (From: "Robert Černý" <email@hidden>)
 >Re: Hex representation of NSString (From: Negm-Awad Amin <email@hidden>)
 >Re: Hex representation of NSString (From: "Robert Černý" <email@hidden>)
 >Re: Hex representation of NSString (From: Jason Coco <email@hidden>)
 >Re: Hex representation of NSString (From: "Clark Cox" <email@hidden>)
 >Re: Hex representation of NSString (From: Jason Coco <email@hidden>)

  • Prev by Date: Re: Right place to unobserve notifications in a document
  • Next by Date: Re: Table column header not highlighted at first
  • Previous by thread: Re: Hex representation of NSString
  • Next by thread: Re: Hex representation of NSString
  • Index(es):
    • Date
    • Thread