Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

c# - How to decode a Unicode character in a string

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Regex.Unescape did the trick:

System.Text.RegularExpressions.Regex.Unescape(@"Schu00f6nen");

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...