Skip to content

Commit 0927ceb

Browse files
committed
Update frameworks
1 parent 5bd38d7 commit 0927ceb

3 files changed

Lines changed: 12 additions & 29 deletions

File tree

readme.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
[![NuGet](https://img.shields.io/nuget/dt/Unidecode.NET.svg)](https://www.nuget.org/packages/Unidecode.NET)
66
[![License MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
77

8-
Support <img src="https://img.shields.io/badge/.net-4.5-green.svg"></img>, <img src="https://img.shields.io/badge/.netstandard-1.2-green.svg"></img>, <img src="https://img.shields.io/badge/.netstandard-2.0-green.svg"></img>
9-
108
# Purpose
119
It often happens that you have text data in Unicode, but you need to represent it in ASCII. For example when integrating with legacy code that doesn’t support Unicode, or for ease of entry of non-Roman names on a US keyboard, or when constructing ASCII machine identifiers from human-readable Unicode strings that should still be somewhat intelligible (a popular example of this is when making an URL slug from an article title).
1210

src/Unidecode.NET.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
<AssemblyName>Unidecode.NET</AssemblyName>
55
<PackageId>Unidecode.NET</PackageId>
66
<Authors>Dima Stefantsov, Vitalii Ganzha, Sergey Kuznetsov</Authors>
7-
<Copyright>2019 © Dima Stefantsov, Vitalii Ganzha, Sergey Kuznetsov</Copyright>
7+
<Copyright>2020 © Dima Stefantsov, Vitalii Ganzha, Sergey Kuznetsov</Copyright>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<Description>Unidecode.NET returns transliterated string</Description>
11-
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard1.2;netstandard2.0;net45</TargetFrameworks>
12-
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.2;netstandard2.0</TargetFrameworks>
13-
<VersionPrefix>1.4.0</VersionPrefix>
11+
<TargetFrameworks>netstandard1.2;netstandard2.0;netstandard2.1</TargetFrameworks>
12+
<VersionPrefix>1.5.0</VersionPrefix>
1413
<PackageTags>text;unicode;seo</PackageTags>
1514
<RepositoryType>git</RepositoryType>
1615
<PackageProjectUrl>https://github.com/thecoderok/Unidecode.NET</PackageProjectUrl>

src/Unidecoder.cs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,14 @@ public static partial class Unidecoder
2424
public static string Unidecode(this string input, int? tempStringBuilderCapacity = null)
2525
{
2626
if (string.IsNullOrEmpty(input))
27-
{
2827
return "";
29-
}
30-
28+
3129
if (input.All(x => x < 0x80))
32-
{
3330
return input;
34-
}
35-
36-
31+
3732
// Unidecode result often can be at least two times longer than input string.
3833
var sb = new StringBuilder(tempStringBuilderCapacity ?? input.Length * 2);
39-
foreach (char c in input)
34+
foreach (var c in input)
4035
{
4136
// Copypaste is bad, but sb.Append(c.Unidecode()); would be a bit slower.
4237
if (c < 0x80)
@@ -45,10 +40,9 @@ public static string Unidecode(this string input, int? tempStringBuilderCapacity
4540
}
4641
else
4742
{
48-
int high = c >> 8;
49-
int low = c & 0xff;
50-
string[] transliterations;
51-
if (characters.TryGetValue(high, out transliterations))
43+
var high = c >> 8;
44+
var low = c & 0xff;
45+
if (characters.TryGetValue(high, out var transliterations))
5246
{
5347
sb.Append(transliterations[low]);
5448
}
@@ -75,17 +69,9 @@ public static string Unidecode(this char c)
7569
}
7670
else
7771
{
78-
int high = c >> 8;
79-
int low = c & 0xff;
80-
string[] transliterations;
81-
if (characters.TryGetValue(high, out transliterations))
82-
{
83-
result = transliterations[low];
84-
}
85-
else
86-
{
87-
result = "";
88-
}
72+
var high = c >> 8;
73+
var low = c & 0xff;
74+
result = characters.TryGetValue(high, out var transliterations) ? transliterations[low] : "";
8975
}
9076

9177
return result;

0 commit comments

Comments
 (0)