Re: Getting Rid of the Nulls
From: J.Marsch (jeremy_at_ctcdeveloper.com)
Date: 04/13/04
- Next message: dln: "Quick Mutex Question"
- Previous message: alontm: "Problem with PPE Messenger included in SDK 6"
- In reply to: Drew: "Getting Rid of the Nulls"
- Next in thread: Michael Giagnocavo [MVP]: "Re: Getting Rid of the Nulls"
- Reply: Michael Giagnocavo [MVP]: "Re: Getting Rid of the Nulls"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 13 Apr 2004 11:01:18 -0500
Drew:
It looks as though Andreas has your root problem fixed. If you still need
to perform the trim, you can use
string newString = oldString.Trim('\0') (note the single quotes, not double
quotes)
I'm not sure why String.Trim(null); doesn't work. According to the help, it
should be exactly what you are after.
"Drew" <someone@hotmail.com> wrote in message
news:uJW2moWIEHA.3356@TK2MSFTNGP11.phx.gbl...
> I have been using System.Text.Encoding.Unicode.GetString(byte[],0,72)
> to converter a byte array from the registry to a string.
>
> This works, but I end up with a bunch of null characters after
> the "good" string data that I need to parse. This is evidenced
> by the fact that string.length returns 36 when the actual string
> data I need to work with is usually much less.
>
> I tried using String.Trim(null) but this doesn't achieve the desired
result.
>
> The only thing I can think of is to convert the string to a char array
> and loop through until I hit a null character.
>
> Is there a better way to get rid of the nulls?
>
> If I could just get the actual length of the string that would help.
>
> Thanks,
>
> Drew
>
>
>
>
- Next message: dln: "Quick Mutex Question"
- Previous message: alontm: "Problem with PPE Messenger included in SDK 6"
- In reply to: Drew: "Getting Rid of the Nulls"
- Next in thread: Michael Giagnocavo [MVP]: "Re: Getting Rid of the Nulls"
- Reply: Michael Giagnocavo [MVP]: "Re: Getting Rid of the Nulls"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|