Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert ’ to apostrophe in C#?

Tags:

c#

I have tried several combinations of ASCII, Latin1, Windows-1252, UTF-8 and Unicode to convert ’ to apostrophe in C#, but to no avail.

byte[] uBytes = Encoding.Unicode.GetBytes(questionString);
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, uBytes);
string converted = Encoding.UTF8.GetString(utf8Bytes);

I am using this conversion chart to discover what each code should be: http://www.i18nqa.com/debug/utf8-debug.html

like image 566
Matt Hudson Avatar asked Jun 04 '12 20:06

Matt Hudson


People also ask

What is â € TM?

html - An apostrophe is rendering as â€tm.

What is this character â?

Â, â (a-circumflex) is a letter of the Inari Sami, Skolt Sami, Romanian, and Vietnamese alphabets. This letter also appears in French, Friulian, Frisian, Portuguese, Turkish, Walloon, and Welsh languages as a variant of the letter "a". It is included in some romanization systems for Persian, Russian, and Ukrainian.

Does C use utf8?

Most C string library routines still work with UTF-8, since they only scan for terminating NUL characters.


1 Answers

Try the following:

var bytes = Encoding.Default.GetBytes("’");
var text = Encoding.UTF8.GetString(bytes);
Console.WriteLine(text);
like image 115
Muhammad Hasan Khan Avatar answered Sep 21 '22 23:09

Muhammad Hasan Khan