Basically what I'm trying to do is replace a symbol like ™, ® etc with something else but when I call
myString = myString.Replace("®", "something else")
Its doesn't do anything
Any Ideas?
Basically what I'm trying to do is replace a symbol like ™, ® etc with something else but when I call
myString = myString.Replace("®", "something else")
Its doesn't do anything
Any Ideas?
It may be likely that C# does not like the literal registered symbol. I would suggest trying to replace the character by using a character code, using either the integral value, hex, or unicode.
Below is an example using the integral value of the character ®.
string originalString = "whatever®";
string stuff = "something else";
char registered = (char)174;
string replacedString = originalString.Replace(registered, stuff);
Try to use Unicode characters to replace this symbols.
string x = "® ™ dwdd2";
string y = x.Replace('\u00AE', 'X');
It's working ;-)
http://msdn.microsoft.com/en-us/library/aa664669%28v=vs.71%29.aspx
And a list of Charakters:
It works for me:
var myString = "Hello world ®, will this work?";
var result = myString.Replace("®", "something else");
Console.WriteLine(result);
results in:
Hello world something else, will this work?
You can see it run here.
Does your original string really contain that character or does it contain something like an html entity: ® or ® or other "encoded" version of that character?