<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: accents code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 14:17:17 GMT</pubDate>
    <description>DZone Snippets: accents code</description>
    <item>
      <title>String Translit for Rails</title>
      <link>http://snippets.dzone.com/posts/show/5609</link>
      <description>// Translit for Rails using ActiveSupport. (convert &#233; in e and other utf8 codes in latin chars)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class String&lt;br /&gt;  def translit&lt;br /&gt;    ActiveSupport::Multibyte::Handlers::UTF8Handler.normalize(self,:d).split(//u).reject { |e| e.length &gt; 1 }.join&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 06 Jun 2008 22:03:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5609</guid>
      <author>mattetti (Matt Aimonetti)</author>
    </item>
    <item>
      <title>Strip accents</title>
      <link>http://snippets.dzone.com/posts/show/5499</link>
      <description>// Strip accents from a string. For example, "Sigur R&#243;s" =&gt; "Sigur Ros".&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def strip_accents(string):&lt;br /&gt;  import unicodedata&lt;br /&gt;  return unicodedata.normalize('NFKD', unicode(string)).encode('ASCII', 'ignore')&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 16 May 2008 00:19:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5499</guid>
      <author>pyninja (Adeel Khan)</author>
    </item>
    <item>
      <title>Nice post slug</title>
      <link>http://snippets.dzone.com/posts/show/2384</link>
      <description>This code replaces accents to normal chars(e.g "&#195;&#161;" =&gt; "a"), everything that isn&#194;&#180;t in "a-zA-Z0-9" to "", multiples spaces to one space, and one space to "-".&lt;br /&gt;&lt;br /&gt;This is useful to make URLs from titles, like Netscape.com does...&lt;br /&gt;&lt;br /&gt;"A new report recommends only work 4 -6 hrs a day" =&gt; "A-new-report-recommends-only-work-4-6-hrs-a-day"&lt;br /&gt;&lt;br /&gt;"Video: \"Popular Mechanics\" editor debunks 9/11 myths" =&gt; "Video-Popular-Mechanics-editor-debunks-911-myths"&lt;br /&gt;&lt;br /&gt;etc..&lt;br /&gt;The code is 95% based on http://textsnippets.com/posts/show/451&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def self.nice_slug(str)&lt;br /&gt;		&lt;br /&gt;		accents = { &lt;br /&gt;		  ['&#195;&#161;','&#195;&#160;','&#195;&#162;','&#195;&#164;','&#195;&#163;'] =&gt; 'a',&lt;br /&gt;		  ['&#195;&#402;','&#195;&#8222;','&#195;&#8218;','&#195;&#8364;','&#195;?'] =&gt; 'A',&lt;br /&gt;		  ['&#195;&#169;','&#195;&#168;','&#195;&#170;','&#195;&#171;'] =&gt; 'e',&lt;br /&gt;		  ['&#195;&#8249;','&#195;&#8240;','&#195;&#710;','&#195;&#352;'] =&gt; 'E',&lt;br /&gt;		  ['&#195;&#173;','&#195;&#172;','&#195;&#174;','&#195;&#175;'] =&gt; 'i',&lt;br /&gt;		  ['&#195;?','&#195;&#381;','&#195;&#338;','&#195;?'] =&gt; 'I',&lt;br /&gt;		  ['&#195;&#179;','&#195;&#178;','&#195;&#180;','&#195;&#182;','&#195;&#181;'] =&gt; 'o',&lt;br /&gt;		  ['&#195;&#8226;','&#195;&#8211;','&#195;&#8221;','&#195;&#8217;','&#195;&#8220;'] =&gt; 'O',&lt;br /&gt;		  ['&#195;&#186;','&#195;&#185;','&#195;&#187;','&#195;&#188;'] =&gt; 'u',&lt;br /&gt;		  ['&#195;&#353;','&#195;&#8250;','&#195;&#8482;','&#195;&#339;'] =&gt; 'U',&lt;br /&gt;		  ['&#195;&#167;'] =&gt; 'c', ['&#195;&#8225;'] =&gt; 'C',&lt;br /&gt;		  ['&#195;&#177;'] =&gt; 'n', ['&#195;&#8216;'] =&gt; 'N'&lt;br /&gt;		  }&lt;br /&gt;		accents.each do |ac,rep|&lt;br /&gt;		  ac.each do |s|&lt;br /&gt;			str = str.gsub(s, rep)&lt;br /&gt;		  end&lt;br /&gt;		end&lt;br /&gt;		str = str.gsub(/[^a-zA-Z0-9 ]/,"")&lt;br /&gt;		&lt;br /&gt;		str = str.gsub(/[ ]+/," ")&lt;br /&gt;		&lt;br /&gt;&lt;br /&gt;		str = str.gsub(/ /,"-")&lt;br /&gt;		&lt;br /&gt;		#str = str.downcase&lt;br /&gt;&lt;br /&gt;	end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 10 Aug 2006 00:09:27 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2384</guid>
      <author>sligowaths (Tiago Serafim)</author>
    </item>
  </channel>
</rss>
