473,503 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String.Length issue

Hi. I've got a vb.net/asp.net application that passes strings back a
forth between a c++ COM object. We use simple tagging to designate
what's what, and it's worked pretty well until now. We had some data
that wasn't parsing right because it also contained tags that conflicted
with the tags designating the data.
To get around this the programmer of the COM object (not me) decided we
could put string lengths in the tags, so if an element was called x, I'd
send <x L=3>123</x> with the L= indicating the length of the string. So
I wrote a tagging function to take care of this that uses the
String.Length property to calculate the length of the string. Then I
send the following string, and he can't parse it out:

<body L=579>Dear MATT B---

Thanks for purchasing Print@Home tickets!
Included in this this email is a link to your ticket(s) from sale id
**SUB(wwsale_id).
To retrieve your tickets, please click (or copy/paste into your browser)
the link below:
<http://localhost/webwaresales1/GetTix.aspx?req=kXU%2bANUsFnl4YlNHjua5lA%3d%3d>

You will need Adobe Acrobat Reader (available free from
http://www.adobe.com)
to view or print your items.

You will need to bring your printed tickets with you to the resort.

Thanks again and we look forward to seeing you soon!

S---------, Inc.</body>
The other guy said he calculates a length of 551 but if I use
String.Length I get 579. Incidentally, if I paste the string into
TextPad and look at the document properties, it says 551 characters and
a file size of 579.
So can anyone explain where the difference (28) comes from? It's not the
number of lines (15) and I don't see any other special characters
besides line endings.

Thanks!

Matt
Nov 19 '05 #1
1 1294
MattB <so********@yahoo.com> wrote in news:3n*************@individual.net:
The other guy said he calculates a length of 551 but if I use
String.Length I get 579. Incidentally, if I paste the string into
TextPad and look at the document properties, it says 551 characters and
a file size of 579.
So can anyone explain where the difference (28) comes from? It's not the
number of lines (15) and I don't see any other special characters
besides line endings.


Line endings actually take up 2 bytes in Windows. Carriage Return and Line
Feed.

So 579 bytes is correct - there are 15 lines, but only 14 CR + LF. So:

551 bytes + (14 CRLF x 2 bytes) = 579 : )

BTW, didn't the other guy calculate 579 too? (<body L=579>).

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2

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

Similar topics

5
20050
by: Rick | last post by:
For some reason my function to capitalize the first letter in a string and keep all the other letters lowercase isn't working. This is what I have. string convname(string name) { int len;...
8
4720
by: Hal Vaughan | last post by:
Is there a maximum length for Javascript program lines? What about strings? Is there a limit on string length? I found some references that said the maximum string length was 256 characters,...
4
13627
by: Jason Gleason | last post by:
What's the most efficient way to get the number of occurences of a certain string in another string..for instance i'm using the following code right now... private int CharacterCounter(String...
17
4635
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
53
4020
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
47
4956
by: sudharsan | last post by:
could any one please give me a code to reverse a string of more than 1MB .??? Thanks in advance
7
7796
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}"...
14
4045
by: Shhnwz.a | last post by:
Hi, I am in confusion regarding jargons. When it is technically correct to say.. String or Character Array.in c. just give me your perspectives in this issue. Thanx in Advance.
15
50132
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
0
7205
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
7287
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,...
1
7008
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
7467
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...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.