Convert Full Width to Half Width

In C #, how do I convert a string that uses full-width shape characters to half-width shape characters?

For example, when using userInput below, I want to convert Stackoverflow to Stackoverflow :

 string userInput= "Stackoverflow"; //string userInput= "Stackoverflow"; 
+10
c # unicode
source share
1 answer

You can use the string.Normalize() method:

 string userInput = "Stackoverflow"; string result = userInput.Normalize(NormalizationForm.FormKC); //result = "Stackoverflow" 

See an example on DotNetFiddle .

Further information on normalization forms can be found at unicode.org .

+16
source share

All Articles