<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fredrik Haglund's blog &#187; Snippets</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Tue, 28 Jun 2011 13:37:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>C# Code: How to transform &#197;&#228;&#246; to Aao</title>
		<link>http://blog.fredrikhaglund.se/blog/2008/04/16/how-to-remove-diacritic-marks-from-strings/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2008/04/16/how-to-remove-diacritic-marks-from-strings/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 13:28:13 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=151</guid>
		<description><![CDATA[I have extended the Friendly Url Rewriter in one project to rewrite all URL:s following a specific pattern to a search page. Search Engine Optimization (SEO) with Friendly URL Rewriter Instead of having to use URL that looks like this: http://www.example.com/Search.aspx?country=åland?type=hotel We accept URL:s in a more friendly format and rewrite internally to the format [...]]]></description>
			<content:encoded><![CDATA[<p>I have extended the Friendly Url Rewriter in one project to rewrite all URL:s following a specific pattern to a search page.</p>
<h3>Search Engine Optimization (SEO) with Friendly URL Rewriter</h3>
<p>Instead of having to use URL that looks like this:</p>
<p><code>http://www.example.com/Search.aspx?country=åland?type=hotel</code></p>
<p>We accept <a href="http://blog.fredrikhaglund.se/wp-admin/s">URL:s</a> in a more friendly format and rewrite internally to the format above with parameters:</p>
<p><code>http://www.example.com/åland-hotel.html</code></p>
<p>There exists no file with that name on the server instead we recognize the pattern  with a regular exception like this one:</p>
<p><code>^(?&lt;country&gt;.+)-(?&lt;type&gt;.+)\.html$</code></p>
<h3>Google AdWords does not allow diacritic marks in URLS</h3>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2008/04/image8.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 10px 0px 0px; border-right-width: 0px" src="http://blog.fredrikhaglund.se/wp-content/uploads/2008/04/image-thumb4.png" border="0" alt="image" width="188" height="171" align="left" /></a> Using letters with accents, rings and umlaut a url is not allowed with Google AdWords so we needed a generic matching algorithm that would both recognize &#8220;aland&#8221; and &#8220;åland&#8221; when comparing search parameters.</p>
<p>There is a nice Unicode function, <em>String.Normalize()</em>, that makes it very easy to transform unwanted characters into something allowed.</p>
<p><a href="http://weblogs.asp.net/fmarguerie/archive/2006/10/30/removing-diacritics-accents-from-strings.aspx">Fabrice wrote a snippet of code to transform Åäö to Aao</a> that I used:</p>
<pre><code>public static String RemoveDiacritics(string s)
{
    string normalizedString = s.Normalize(NormalizationForm.FormD);
    StringBuilder stringBuilder = new StringBuilder();
    for (int i = 0; i &lt; normalizedString.Length; i++)
    {
        char c = normalizedString[i];
        if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
            stringBuilder.Append(c);
    }
    return stringBuilder.ToString();
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2008/04/16/how-to-remove-diacritic-marks-from-strings/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

