String.Length issue

M

MattB

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+ANUsFnl4YlNHjua5lA==>

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
 
L

Lucas Tam

MattB said:
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>).
 

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

Members online

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,293
Latest member
BonnieHamb

Latest Threads

Top