summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Extensions
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF/Extensions')
-rw-r--r--win/CS/HandBrakeWPF/Extensions/StringExtensions.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs
new file mode 100644
index 000000000..35cf4b128
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs
@@ -0,0 +1,41 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="StringExtensions.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// String Extensions
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Extensions
+{
+ using System.Text;
+
+ /// <summary>
+ /// String Extensions
+ /// </summary>
+ public static class StringExtensions
+ {
+ /// <summary>
+ /// Change the input string to title case
+ /// </summary>
+ /// <param name="input">the input string</param>
+ /// <returns>the input string in title case</returns>
+ 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();
+ }
+ }
+}