Getting bytes from a string

  • Thread starter Thread starter Chris Leffer
  • Start date Start date
C

Chris Leffer

Hi.

My application has a textbox that can receive a lengthful string from
the user. I need to separate this string into blocks of 50 bytes and
process each block to compose a text file. I have the majority of the
routine ready, but how can I divide the string into blocks of 50 bytes?

Regards,
Chris Leffer
 
Chris Leffer said:
My application has a textbox that can receive a lengthful string from
the user. I need to separate this string into blocks of 50 bytes and
process each block to compose a text file. I have the majority of the
routine ready, but how can I divide the string into blocks of 50 bytes?

'System.Text.Encoding.<encoding name>.GetBytes'.
 
Hi Herfried!

Thanks, the GetBytes method works ok. But it takes each character as an
element of the array. How can I tell it to get groups of 50 characters?

Regards,
Chris Leffer
 
Just deal with the resulting array in chunks of 50 bytes. 0 to 49, 50 to 99
etc.
 
Chris,

You know that a character is unicode which exist in 2 bytes.

Maybe are you just looking for this.

String.indexof(0,50)
string.indexof(50,50)
etc
or the
Mid statement

Cor
 
Chris Leffer said:
Thanks, the GetBytes method works ok. But it takes each character as an
element of the array. How can I tell it to get groups of 50 characters?

In addition to the other replies note that 1 character <> 1 byte.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top