Mercurial > repos > IBBoard
diff Lang/StringManipulation.cs @ 37:cc7fae81afec
* Fix line terminators
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 27 Jun 2009 19:03:58 +0000 |
parents | 23fd4247fc1c |
children | a5714f82073d |
line wrap: on
line diff
--- a/Lang/StringManipulation.cs Tue May 19 19:55:21 2009 +0000 +++ b/Lang/StringManipulation.cs Sat Jun 27 19:03:58 2009 +0000 @@ -2,26 +2,26 @@ // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. -using System; -using System.Text; - -namespace IBBoard.Lang -{ - /// <summary> - /// Summary description for StringManipulation. - /// </summary> - public class StringManipulation - { - private static Encoding utf8; - - static StringManipulation() - { - utf8 = Encoding.UTF8; - } - - public static byte[] StringToBytes(string str) - { - return utf8.GetBytes(str); +using System; +using System.Text; + +namespace IBBoard.Lang +{ + /// <summary> + /// Summary description for StringManipulation. + /// </summary> + public class StringManipulation + { + private static Encoding utf8; + + static StringManipulation() + { + utf8 = Encoding.UTF8; + } + + public static byte[] StringToBytes(string str) + { + return utf8.GetBytes(str); } public static string ByteArrayToHexString(byte[] arr) @@ -40,27 +40,27 @@ } return sb.ToString().TrimEnd(); - } - - public static string RemoveFromLast(string stringToTrim, char removeFrom) - { - return stringToTrim.Substring(0, stringToTrim.LastIndexOf(removeFrom)); - } - - public static string CutToLength(string stringToShorten, int length) - { - int strLength = stringToShorten.Length; - - if (length >= strLength-2) - { - return stringToShorten; - } - else - { - int diff = (strLength - length) / 2; - int halfLength = strLength / 2; - return stringToShorten.Substring(0, halfLength - diff)+"..."+stringToShorten.Substring(halfLength + diff); - } - } - } -} + } + + public static string RemoveFromLast(string stringToTrim, char removeFrom) + { + return stringToTrim.Substring(0, stringToTrim.LastIndexOf(removeFrom)); + } + + public static string CutToLength(string stringToShorten, int length) + { + int strLength = stringToShorten.Length; + + if (length >= strLength-2) + { + return stringToShorten; + } + else + { + int diff = (strLength - length) / 2; + int halfLength = strLength / 2; + return stringToShorten.Substring(0, halfLength - diff)+"..."+stringToShorten.Substring(halfLength + diff); + } + } + } +}