From dda2863c2aa895c6650e68cc1f56c6e1522dd91b Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 1 Oct 2017 15:11:21 +0100 Subject: WinGui; Implement a smarter Title Case Algorithm. This may resolve #922 --- win/CS/HandBrakeWPF/Extensions/StringExtensions.cs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'win/CS/HandBrakeWPF/Extensions') diff --git a/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs index 35cf4b128..d09c99e20 100644 --- a/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs +++ b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs @@ -9,13 +9,13 @@ namespace HandBrakeWPF.Extensions { - using System.Text; + using System.Globalization; /// /// String Extensions /// public static class StringExtensions - { + { /// /// Change the input string to title case /// @@ -23,19 +23,8 @@ namespace HandBrakeWPF.Extensions /// the input string in title case public static string ToTitleCase(this string input) { - string[] tokens = input.Split(' '); - StringBuilder sb = new StringBuilder(input.Length); - foreach (string s in tokens) - { - if (!string.IsNullOrEmpty(s)) - { - sb.Append(s[0].ToString().ToUpper()); - sb.Append(s.Substring(1).ToLower()); - sb.Append(" "); - } - } - - return sb.ToString().Trim(); + TextInfo textInfo = new CultureInfo(CultureInfo.CurrentCulture.Name, false).TextInfo; + return textInfo.ToTitleCase(input); } } } -- cgit v1.2.3