C # String.Replace not finding / replacing Symbol (™, ®)

Basically what I'm trying to do is replace a character like ™, ®, etc. something else but when i call

myString = myString.Replace ("®", "something else")

It does nothing

Any ideas?

+5
source share
7 answers

try myString.Replace ("\ u00A9", "else"); you must avoid ©

+6
source

When you use String.Replace, you create a new line. A very common mistake is that the changed string has been changed. However, strings in .NET are immutable and cannot be changed.

You should call it like this:

myString = myString.Replace("®", "something else");
+6
source

, Replace -.

, , - :

myString = myString.Replace("®", "something else");
+2

, # . , , , .

®.

string originalString = "whatever®";
string stuff = "something else";
char registered = (char)174;
string replacedString = originalString.Replace(registered, stuff);

ref: http://msdn.microsoft.com/en-us/library/x9h8tsay.aspx

+1

, string.Replace ,

myString = myString.Replace("®", "something else");
0

Unicode .

        string x = "® ™ dwdd2";
        string y = x.Replace('\u00AE', 'X');

; -)

http://msdn.microsoft.com/en-us/library/aa664669%28v=vs.71%29.aspx

Charakters:

http://en.wikipedia.org/wiki/List_of_Unicode_characters

0

:

var myString = "Hello world ®, will this work?";
var result = myString.Replace("®", "something else");
Console.WriteLine(result);

:

Hello world, will this work?

You can see it here .

Does your original string really contain this character or contain something like an html object: ®or ®or another "encoded" version of this character?

0
source

All Articles