Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS: Peak file now generating in background when a song starts playing.
PeakFile.cs has been renamed to PeakFileGenerator.cs and is no longer dependent on System.Reactive. Added Normalizer class to MPfm.Core. Related to issue #323 and issue #405.
- Loading branch information
1 parent
5d1e117
commit 75edef4
Showing
7 changed files
with
778 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright © 2011-2013 Yanick Castonguay | ||
// | ||
// This file is part of MPfm. | ||
// | ||
// MPfm is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// MPfm is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with MPfm. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Globalization; | ||
|
||
namespace MPfm.Core | ||
{ | ||
/// <summary> | ||
/// Normalizing class for strings and other objects. | ||
/// </summary> | ||
public static class Normalizer | ||
{ | ||
/// <summary> | ||
/// Normalizes a string for URL. | ||
/// Taken from http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net | ||
/// </summary> | ||
public static string NormalizeStringForUrl(string name) | ||
{ | ||
String normalizedString = name.Normalize(NormalizationForm.FormD); | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
|
||
foreach (char c in normalizedString) | ||
{ | ||
switch (CharUnicodeInfo.GetUnicodeCategory(c)) | ||
{ | ||
case UnicodeCategory.LowercaseLetter: | ||
case UnicodeCategory.UppercaseLetter: | ||
case UnicodeCategory.DecimalDigitNumber: | ||
stringBuilder.Append(c); | ||
break; | ||
case UnicodeCategory.SpaceSeparator: | ||
case UnicodeCategory.ConnectorPunctuation: | ||
case UnicodeCategory.DashPunctuation: | ||
stringBuilder.Append('_'); | ||
break; | ||
} | ||
} | ||
string result = stringBuilder.ToString(); | ||
return String.Join("_", result.Split(new char[] { '_' } | ||
, StringSplitOptions.RemoveEmptyEntries)); // remove duplicate underscores | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.