I assume that this is Java code and not C code.  Is that right?

Are you sure that you posted your code correctly?  When I try what
you've done, I get an IndexOutOfBoundsException when executing
sZero.charAt(1), which is what I would expect.

Also, are you sure you're getting 65533 and not 65535?  If you convert
a value of -1 to an unsigned 16-bit integer, you get 65535.  If you
don't understand why, search the web for how negative integers are
stored at the bit level.  So, this might be related.

Also, it sounds like you want to control things at the byte level.  If
so, you probably want to use the "byte" data type and stay away from
char and int and String.  Don't think of a String as an array of
bytes, because it's not (in Java).  It's more list a list of
"characters" WHERE each "character" might actually take up more than
one byte because of internationalization support.

So perhaps you should be working with "byte" instead of "char",
assuming you're trying to manipulate things at the byte level.

-- PJ



On Nov 14, 9:42 am, Joes <joyj...@gmail.com> wrote:
> I just wanna know, with what condition can cause this issue.  I think
> it's probably because of the charset setup which is controlled by
> makefile or something else. I need a direction to look into.
>
> Thanks
>
> On Nov 14, 9:18 am, Andrei <gml...@gmail.com> wrote:
>
>
>
> > just a guess that u want to do this instead "\\0"
>
> > On Nov 14, 8:58 am, Joes <joyj...@gmail.com> wrote:
>
> > > All,
> > > While I'm programming the Android SMTP code,I met a confused problem
> > > with code similar as the following:
> > >     String str= "\0" username "\0" passwrd;
> > > After executed the code, I found "\0" is intepreted as two
> > > undisplayable char.
> > > Then I executed the folloing debug code:
> > >     String sZero = "\0";
> > >     int iLen = sZero.length();
> > >     int iValue1 = (int)sZero.charAt(0);
> > >     int iValue2 = (int)sZero.charAt(1);
> > >     Log.w("ZERO", "Zero String, Lenth=", iLen, " value1=", iValue1, "
> > > value2=", iValue2);
> > > What I get in screen is :
> > >     Zero String, Length=2 value1=65533 value2=65533.
>
> > > Really confuse me, why "\0" become [65533,65533] in my program?
>
> > > Thanks- Hide quoted text -
>
> > - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to