473,804 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Curious Response.Write behavior with GUIDs as strings

Consider the following:

var GUID = Server.CreateOb ject("Scriptlet .TypeLib").GUID

Let's assume GUID is {9A46FCC9-A7A1-4C96-9394-B1A966CEC081}.

I happened to notice that if I concatenate this with any other string value,
Response.Write aborts after the 38th character of the GUID (the closing
brace):

Response.Write( "xxx" + GUID + "yyy")
--> xxx{9A46FCC9-A7A1-4C96-9094-B1A966CEC081}

But the string *contains* those values:

Response.Write( ("xxx" + GUID + "yyy").substrin g(43))
--> yyy

I first thing that caught my eye was the string length -- two characters
longer than I expected. This helped explain things:

Response.Write( escape("xxx" + GUID + "yyy"))
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00%25yyy
^^^^^^

So my mystery characters are %00%25, right? Wrong. The %00 seems static, but
the next character appears to be random. Reloading a few times revealed no
real pattern (the GUID obviously changes, so this example is a
generalization) :

--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00%25yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %004yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %006yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00Cyyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00%20yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00Dyyy

OK, so the string contains %00 and a garbage character. But what IS that
character? According to http://www.asciitable.com/, it is suppose to be a
(null) character. I can seemingly verify that this is not just a mapping
from a larger character set, since I get a non-zero
indexOf(String. fromCharCode(0) ); more importantly, VBScript's Asc, AscB and
AscW functions all return 0.

It appears, then, that the problem is twofold. First of all, this assertion
is incorrect:
=============== =============== =============== =======
guid = server.CreateOb ject("scriptlet .typelib").guid
Can be replaced with this:
guid = System.Guid.New Guid.ToString()
=============== =============== =============== =======
http://msdn.microsoft.com/asp.net/us...usingasst.aspx

Secondly, this behavior of Response.Write seems unindicated:
http://msdn.microsoft.com/library/en...resomwrite.asp


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #1
11 2360
http://www.aspfaq.com/2358

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:e9******** ******@TK2MSFTN GP09.phx.gbl...
Consider the following:

var GUID = Server.CreateOb ject("Scriptlet .TypeLib").GUID

Let's assume GUID is {9A46FCC9-A7A1-4C96-9394-B1A966CEC081}.

I happened to notice that if I concatenate this with any other string value, Response.Write aborts after the 38th character of the GUID (the closing
brace):

Response.Write( "xxx" + GUID + "yyy")
--> xxx{9A46FCC9-A7A1-4C96-9094-B1A966CEC081}

But the string *contains* those values:

Response.Write( ("xxx" + GUID + "yyy").substrin g(43))
--> yyy

I first thing that caught my eye was the string length -- two characters
longer than I expected. This helped explain things:

Response.Write( escape("xxx" + GUID + "yyy"))
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00%25yyy
^^^^^^

So my mystery characters are %00%25, right? Wrong. The %00 seems static, but the next character appears to be random. Reloading a few times revealed no
real pattern (the GUID obviously changes, so this example is a
generalization) :

--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00%25yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %004yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %006yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00Cyyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00%20yyy
--> xxx%7B9A46FCC9-A7A1-4C96-9094-B1A966CEC081%7D %00Dyyy

OK, so the string contains %00 and a garbage character. But what IS that
character? According to http://www.asciitable.com/, it is suppose to be a
(null) character. I can seemingly verify that this is not just a mapping
from a larger character set, since I get a non-zero
indexOf(String. fromCharCode(0) ); more importantly, VBScript's Asc, AscB and AscW functions all return 0.

It appears, then, that the problem is twofold. First of all, this assertion is incorrect:
=============== =============== =============== =======
guid = server.CreateOb ject("scriptlet .typelib").guid
Can be replaced with this:
guid = System.Guid.New Guid.ToString()
=============== =============== =============== =======
http://msdn.microsoft.com/asp.net/us...usingasst.aspx
Secondly, this behavior of Response.Write seems unindicated:
http://msdn.microsoft.com/library/en...resomwrite.asp


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #2
Aaron [SQL Server MVP] wrote:
http://www.aspfaq.com/2358


[sigh] I should have looked there.

BTW - do you have any idea why the last character is garbage?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3
No, that was one of those "we'll get back to you on that" things that I
reported around the time ASP.Net came into being. I've long since abandoned
any hope that ASP bugs will get any attention. Maybe I should raise the
issue about .Net though, because I have also seen it there...

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:#v******** ******@TK2MSFTN GP11.phx.gbl...
Aaron [SQL Server MVP] wrote:
http://www.aspfaq.com/2358
[sigh] I should have looked there.

BTW - do you have any idea why the last character is garbage?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #4
It looks like the GUID property is returning a null-terminated string in a
40 character buffer. I have to conclude that this is a bug in a conversion
routine somewhere.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
Aaron [SQL Server MVP] wrote:
http://www.aspfaq.com/2358
[sigh] I should have looked there.

BTW - do you have any idea why the last character is garbage?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #5
Mark Schupp wrote:
It looks like the GUID property is returning a null-terminated string
in a 40 character buffer. I have to conclude that this is a bug in a
conversion routine somewhere.


I asked Eric Lippert, and he confirmed this. He also claimed responsibility:

...I was supposed to allocate 38 characters for the guid. For
some stupid reason I allocated 40 characters. A BSTR is
automatically terminated with a zero, so there's no need to
worry about it.

That is, the layout of the BSTR was supposed to be length = 38,
"{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" zero but turned out to
be length = 40, "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx}" zero
one-garbage-character zero

The garbage character is whatever happened to be on the heap
when the allocator fetched it...


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #6
So, Dave, do you have an enemy in Houston? A scorned lover, perhaps? ;-)

I forwarded several of the offensive messages, with headers, to google abuse
and his/her ISP. Hopefully someone smacks him/her upside the head for being
a childish pissant.
Jul 19 '05 #7
Aaron [SQL Server MVP] wrote:
So, Dave, do you have an enemy in Houston?
I may. I lived in Texas for 15 years, and I am, in fact, a Texas Aggie.
Years ago, I was an austin.general regular, and that group had plenty of
Houston contributors.
A scorned lover, perhaps?
;-)
If so, it was a one-way relationship, of which I was not made aware. I
suppose it could pre-date my current relationship, but that one dates to
1984 (and we've been married since 1985), so it would have to be one
extremely persistent grudge.
I forwarded several of the offensive messages, with headers, to
google abuse and his/her ISP. Hopefully someone smacks him/her
upside the head for being a childish pissant.


Thank you, though I'm not convinced it was directed at me. I have never
posted to any of the other groups listed, and I don't exactly have an
unusual name.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #8
> Thank you, though I'm not convinced it was directed at me. I have never
posted to any of the other groups listed, and I don't exactly have an
unusual name.


The other groups seem to have been picked at random. In any case, that kind
of grade-school nonsense has no place here, no matter who it was directed
at. I would have complained even if it were against Zane or CC. ;-)
Jul 19 '05 #9
> The other groups seem to have been picked at random.

Scratch that. I thought I saw different Newsgroups: lists, but looking
back, I was mistaken.
Jul 19 '05 #10

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

Similar topics

13
4771
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of Response.Writes. Are there any tools that will let you design the form then convert that form to Response.Writes that you can further customize with ASP logic? For instance: use Dreamweaver to design the form, then another program to convert to...
35
34517
by: Eitan | last post by:
Hello, How can I write a line (with carriage return + line feed) to the client ? response.write("abcd"), continue the last line, and doesn't put cr+lf. response.writeLn is illegal syntax... Thank :)
35
1742
by: Stan Milam | last post by:
The following code implements a strcat-like function which can receive a variable number of arguments. I thought it would be faster if I kept a pointer to the end of the string as it is built so that strcat() would not always have to find the end of the string as it gets longer and longer. To test this I called the vstrcat() function with a list of pointers, then use the regular strcat() function in a loop to build the same string. ...
1
10985
by: vector | last post by:
I've got an application that generates GUIDs. A lot of GUIDs. Lots of GUIDs that end up in files on disk, taking up space. I'd like to continue using the Guid.NewGuid() function as my unique tag generator, but I'd also like to compress them to base 36 strings, which should retain their uniqueness but save me disk space. I've looked at various base conversion functions, and haven't found a suitable one. Further, I don't need an AnyBase...
3
1704
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while calling the same method same way except for creating object instead directly calling the method? i get this when trying to do that:- ************************************************** Response is not available in this context. Description: An...
1
4494
by: Vish | last post by:
Hi All, I am trying to insert a GUID generated in .NET into my SQL Server tables. I am inserting it into a column of type uniqueidentifier. The GUID generated by ..NET has lower case alphabets in it but after i insert it into the SQL Server tables, all the lower case alphabets get converted into upper case alphabets. This causes problems when i retreive it and compare to the one stored locally in my program. Isn't the GUID case...
10
1921
by: Ron | last post by:
Hi, I currently am generating a report by to my end user by retrieving data from my back end DB and concatenating strings together and place this string concatenation within a Label control. I am finding some efficiencies issues and would like to use Response.Write() and stream this information directly to the aspx page. All of my code is in the code behind and i would like to keep it there.
4
4329
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and response.writes out comma delimited strings so that the results are opened in Excel or saved to a flat file. Basically, it looks something like this like this:
2
3382
by: daveh551 | last post by:
Okay, I asked a question a week or so ago asking for an explanation on relative URL's and the "~" symbol, and several people explained that the "~" is only usable when the URL is going to be parsed by ASP.NET. I have a TreeView control with a hierarchical Category listing of products. Here is the code in selected node changed event: protected void CategoryTreeView_SelectedNodeChanged(object sender, EventArgs e) {
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10087
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9166
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
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.