Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem is, that the specified diacrits have to be explicitly parsed, cause the double points don't exists sole and so the double quotes are used for this case. So to accomplish your problem you don't have any other chance then to implement each needed case.</p> <p>Here is a starting point to get a clue...</p> <pre><code> public SomeFunction() { string asciiChars = "Dutch has funny chars: a,e,u"; string diacrits = " ' \" \""; var combinedChars = asciiChars.Zip(diacrits, (ascii, diacrit) =&gt; { return CombineChars(ascii, diacrit); }); var Result = new String(combinedChars.ToArray()); } private char CombineChars(char ascii, char diacrit) { switch (diacrit) { case '"': return AddDoublePoints(ascii); case '\'': return AddAccent(ascii); default: return ascii; } } private char AddDoublePoints(char ascii) { switch (ascii) { case 'a': return 'ä'; case 'o': return 'ö'; case 'u': return 'ü'; default: return ascii; } } private char AddAccent(char ascii) { switch (ascii) { case 'a': return 'á'; case 'o': return 'ó'; default: return ascii; } } } </code></pre> <p>The IEnumerable.Zip is already <a href="http://msdn.microsoft.com/en-us/library/dd267698(VS.100).aspx" rel="nofollow noreferrer">implemented in .Net 4</a>, but to get it in 3.5 you'll need this code (<a href="http://blogs.msdn.com/ericlippert/archive/2009/05/07/zip-me-up.aspx" rel="nofollow noreferrer">taken from Eric Lippert</a>):</p> <pre><code>public static class IEnumerableExtension { public static IEnumerable&lt;TResult&gt; Zip&lt;TFirst, TSecond, TResult&gt; (this IEnumerable&lt;TFirst&gt; first, IEnumerable&lt;TSecond&gt; second, Func&lt;TFirst, TSecond, TResult&gt; resultSelector) { if (first == null) throw new ArgumentNullException("first"); if (second == null) throw new ArgumentNullException("second"); if (resultSelector == null) throw new ArgumentNullException("resultSelector"); return ZipIterator(first, second, resultSelector); } private static IEnumerable&lt;TResult&gt; ZipIterator&lt;TFirst, TSecond, TResult&gt; (IEnumerable&lt;TFirst&gt; first, IEnumerable&lt;TSecond&gt; second, Func&lt;TFirst, TSecond, TResult&gt; resultSelector) { using (IEnumerator&lt;TFirst&gt; e1 = first.GetEnumerator()) using (IEnumerator&lt;TSecond&gt; e2 = second.GetEnumerator()) while (e1.MoveNext() &amp;&amp; e2.MoveNext()) yield return resultSelector(e1.Current, e2.Current); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload