Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode a Unicode character in a string

Tags:

c#

How do I decode this string 'Sch\u00f6nen' (@"Sch\u00f6nen") in C#, I've tried HttpUtility but it doesn't give me the results I need, which is "Schönen".

like image 777
M_K Avatar asked Feb 15 '12 23:02

M_K


People also ask

How do I decode Unicode characters?

How to decrypt a text with a Unicode cipher? In order make the translation of a Unicode message, reassociate each identifier code its Unicode character. Example: The message 68,67,934,68,8364 is translated by each number: 68 => D , 67 => C , and so on, in order to obtain DCΦD€ .

Can we convert Unicode to text?

Unicode text normalizer tool What is a unicode text normalizer? This online web application normalizes Unicode text. It converts all typographic Unicode glyphs to readable English characters from the ASCII charset.

How do you convert a string with Unicode encoding to a string of letters?

String str1 = "\u0000"; String str2 = "\uFFFF"; String str1 is assigned \u0000 which is the lowest value in Unicode. String str2 is assigned \uFFFF which is the highest value in Unicode.

What are Unicode encoded strings?

Unicode is a standard encoding system that is used to represent characters from almost all languages. Every Unicode character is encoded using a unique integer code point between 0 and 0x10FFFF . A Unicode string is a sequence of zero or more code points.


1 Answers

Regex.Unescape did the trick:

System.Text.RegularExpressions.Regex.Unescape(@"Sch\u00f6nen"); 

Note that you need to be careful when testing your variants or writing unit tests: "Sch\u00f6nen" is already "Schönen". You need @ in front of string to treat \u00f6 as part of the string.

like image 112
M_K Avatar answered Oct 16 '22 16:10

M_K