summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs
blob: cf7e507aaf8e3b867c3978497092746f40443eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// --------------------------------------------------------------------------------------------------------------------
// <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.Globalization;

    /// <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)
        {
            TextInfo textInfo = new CultureInfo(CultureInfo.CurrentCulture.Name, false).TextInfo;
            return textInfo.ToTitleCase(input.ToLower());       
        }

        public static int ToInt(this string input)
        {
            if (int.TryParse(input, out int value))
            {
                return value;
            }

            return 0;
        }
    }
}