Re: ASCII problem
Re: ASCII problem
- Subject: Re: ASCII problem
- From: Will Mason <email@hidden>
- Date: Thu, 2 Jun 2005 08:55:21 -0700 (PDT)
If you don't know the encoding of the data that you're getting, then
how in the world are you turning it into a NSString to begin with? My
suggestion is not to treat it as textual data, but as binary data. If
you feel inclined to bundle it into some kind of object, then use
NSMutableData, not NSString. Then you can get the value of each byte
quite easily.
If it must be text and they don't tell you the encoding of the data
they're sending, then you're left guessing. NSString is not capable of
guessing the encoding.
Good luck,
Will
--- Jim Marschke <email@hidden> wrote:
> My program reads text in from a serial port. This is the output from
>
> a piece of test equipment. I need to convert each character of the
> text to a binary format so that I can interpret it.
>
> I do this in an ugly fashion by converting to ASCII, then converting
>
> to Hex and then to binary.
>
> So, if I receive the letter 'A' it becomes ASCII = 65, hex = 41,
> Binary = 01000001.
>
> The problem is that this equipment sends characters which range from
>
> 0-255 not just 0-127, so I guess it uses an undefined or unofficial
> ASCII table.
>
> I have other serial drivers which can return these values correctly,
>
> so I know it is possible. But, those drivers won't work for this
> application.
>
> If there is a better way to get the binary of the characters I'd love
>
> to know it.
>
> Meanwhile, what I after is a way to figure out the value of the
> character (whether it's ASCII or not) .
>
> Jim Marschke
>
>
> > On 2005-06-02 07:39, Jim Marschke said:
> >
> >
> >> This works fine until I hit a character with an ASCII value
> greater
> >> than 127. After that I get unpredictable results.
> >>
> >
> > ASCII is a 7 bit code:
> > <http://en.wikipedia.org/wiki/Ascii#Overview>
> >
> > You'll have to explain more of what you're trying to do....
> >
> > --
> > ____________________________________________________________
> > Sean McBride, B. Eng email@hidden
> > Rogue Research www.rogue-research.com
> > Mac Software Developer Montréal, Québec, Canada
> >
> >
> >
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden