473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting bytes from a string

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
*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
5 1054
"Chris Leffer" <ch****@wank.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3
Just deal with the resulting array in chunks of 50 bytes. 0 to 49, 50 to 99
etc.
"Chris Leffer" <ch****@wank.com> wrote in message
news:ee*************@TK2MSFTNGP15.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #4
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
Nov 21 '05 #5
"Chris Leffer" <ch****@wank.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike Murray | last post by:
Hi I have the following issue. I have a character that is return by a SQL Server database "É" to be precise, the issue is that when I store character in a .net string variable my understanding...
37
by: MLH | last post by:
For example: Nz(,0) returns "300" if the value in field is 300 (currency data type) and "0" if the value is zero or null. I get strings in the query output - they are all left aligned and I...
17
by: Olivier Bellemare | last post by:
I've tried to make a function that returns the middle of a string. For example: strmid("this is a text",6,4); would return "is a". Here is my code: char *strmid(char *texte, int depart,...
5
by: Drew | last post by:
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...
3
by: Marty | last post by:
Hi, I have this DLL made with VB.NET made as a Class Library project. I know this is managed code. I have my other made with VC++.NET, unmanaged code. The point is that I want to use...
0
by: iwdu15 | last post by:
hi, im creating an instant messenger using TCP sockets, and everythings been fine until now. i want to be able to send rich text, but im hitting a wall here. what i want to do is send the font...
14
by: Ankit Aneja | last post by:
The code of classes given below is for server to which clients connect i want to get ip address of client which has connected pls help how can i get //listen class public class listen {
0
by: ruju00 | last post by:
I am getting an error in Login() method of the following class FtpConnection public class FtpConnection { public class FtpException : Exception { public FtpException(string message) :...
1
by: Flack | last post by:
Hey guys, Here is whats happening. I have a StringBuilder, a TextBox, and a TabControl with one TabPage. On my main form, I created and displayed a fairly big maze. While the app is solving...
1
by: Tenowg | last post by:
Hey everyone... Firstly let me tell you this is a project that is probably alittle over my head... I have played with programming most of my life, but I have only been doing VB 2005 for about 2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.