> Okee, the story goes like this:
>
[quoted text clipped - 5 lines]
> All we did was something like:
> str = str.Replace("_"," ");
-- I hitted the "Submit button by accedent --
Okee, the story goes like this:
I have a string that can not contain spaces (It is retrieved from a
externat application...)
At first they replaced the spaces by '_' so somthing like "ABC DEF"
would be saved as "ABC_DEF".
All we did was something like:
str = str.Replace("_"," ");
So far,so good...
But then I needed to store a '_' in the string....
So we decided to replace the spaces by somthing less common: "%SPACE%"
You think it would by simply
str = str.Replace("%SPACE%", " ");
But: "ABC%SPACE%DEF" result in : "ABCDEF"
Someone any idee?
Jon Skeet [C# MVP] - 15 Jun 2007 10:36 GMT
<snip>
> So we decided to replace the spaces by somthing less common: "%SPACE%"
>
[quoted text clipped - 4 lines]
>
> Someone any idee?
Sounds unlikely.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Christof Nordiek - 15 Jun 2007 10:50 GMT
> You think it would by simply
> str = str.Replace("%SPACE%", " ");
>
> But: "ABC%SPACE%DEF" result in : "ABCDEF"
>
> Someone any idee?
Can't confirm it. I tried following code:
using System;
class A
{
static void Main()
{
string str = "ABC%SPACE%DEF";
str = str.Replace("%SPACE%", " ");
Console.WriteLine(str);
}
}
and it printed "ABC DEF".
Did you check the value in the debugger directly before and after the
replace? Maybe the space got lost somewhere else.
Christof
Stijn VA - 15 Jun 2007 11:26 GMT
> > You think it would by simply
> > str = str.Replace("%SPACE%", " ");
[quoted text clipped - 24 lines]
>
> Christof
Okee, maybe I lose is some where else. I used it in a dll called by an
BizTalk orchestration, I write the string to the event log.. and there
I 'm missing it. And this line was the only thing that has been
chanced...
But if it isn't the replace function, than it shall be something
else...
Stijn VA - 15 Jun 2007 11:42 GMT
FYI
At some point a Batch file was executed to insert the string in the
external app...
So it went looking for an envinment variable %SPACE%, and replaced it
with it value (wich was nothing, because it does not exist....)