question

Alfonso-1498 avatar image
0 Votes"
Alfonso-1498 asked Alfonso-1498 answered

C# string.Replace for removing �?

I am converting hex to a UTF8 string using below line.

var obInstruction = Encoding.UTF8.GetString(ob.Bits);

In the result I got � between every character as shown in the picture below.

what is �?


Result with UTF32
added a picture for the result with UTF32

empty boxes with UTF32


So I added Replace to the line and changed it to var obInstruction = Encoding.UTF8.GetString(ob.Bits).Replace("�", ""); but � won't go away.

When I tried to replace other characters using Replace work fine but not for �.

What is � and how can I remove it?


In Power query, Text.Clean will remove such strange characters but I am not sure how to do in C#.




dotnet-csharppower-query-not-supporteddotnet-aspnet-core-mvc
image.png (9.4 KiB)
image.png (1.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Alfonso-1498 avatar image
0 Votes"
Alfonso-1498 answered

I thought UFT## are only unicode encoding but using 'Unicode' solved the problem!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.